日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Imagination

發布時間:2023/12/18 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Imagination 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Imagination

Time Limit : 3000/1000ms (Java/Other)???Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 8???Accepted Submission(s) : 3

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

There are four matrixs blow , Can you image the NEXT matrix from the given information?

Input

The first line is a integer which represents the case number .
For each test case , there will be a line which contains a integer N (1<=N<=100).

Output

Output the matrix which has N*N integers. Be careful that there is a blank space between two
integer but no blank space after the last integer in a line.

Sample Input

4 1 2 3 4

Sample Output

1 1 2 4 3 1 2 3 8 7 4 9 6 5 1 2 3 4 12 11 10 5 13 14 9 6 16 15 8 7

AC代碼:

?

#include<iostream>
using namespace std;
int p[100][100];

int main()
{
int n,i,j,k,x,y,t;
cin>>t;
while(t--)
{
?cin>>n;
?k=0;
?x=0;
?if(n==1) cout<<1<<endl;
?else
?{
??while(1)
??{
???if(x==n)? break;
???x++;
???for(i=1;i<=n-x+1;i++)
???{
????p[x][i]=++k;
???}
???for(i=x+1;i<=n;i++)
???{
????p[i][n-x+1]=++k;
???}
???if(x==n)? break;
???x++;
???for(i=n;i>=x;i--)
???{
????p[i][n-x+1]=++k;
???}
???for(i=n-x;i>=1;i--)
???{
????p[x][i]=++k;
???}
??}
??for(i=1;i<=n;i++)
??{
???for(j=1;j<=n;j++)
???{
????if(j==n) cout<<p[i][j]<<endl;
????else cout<<p[i][j]<<" ";
???}
??}
?}
}
?return 0;
}

?

?

轉載于:https://www.cnblogs.com/ffhuguang/archive/2012/10/31/2748661.html

總結

以上是生活随笔為你收集整理的Imagination的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。