Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
112603 | 吴诗涵 | 螺旋矩阵 | C++ | Wrong Answer | 1 MS | 280 KB | 668 | 2025-03-09 18:42:47 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int n,a[101][101],k=1; cin>>n; for(int i=1;i<=n;i++){ if(i%2==0){ for(int j=n;j>=1;j--){ a[i][j]=k; k++; } } else{ for(int j=1;j<=n;j++){ a[i][j]=k; k++; } } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ printf("%4d",a[i][j]); } cout<<endl; } return 0; }
------Input------
5
------Answer-----
1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
------Your output-----
1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 21 22 23 24 25