Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
112609 | 吴诗涵 | 螺旋矩阵 | C++ | Compile Error | 0 MS | 0 KB | 711 | 2025-03-09 18:54:23 |
#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; int a[21][21]=(0); cin>>n; int t=1; int i=0; while(t<=n*n){ for(int j=i;j<n-i&&t<=n*n;j++){ a[i][j]=t++; } for(int j=i+1;j<n-i&&t<=n*n;j++){ a[j][n-i-1]=t++; } for(int j=n-i-2&&t<=n*n;j--){ a[n-i-1][j]=t++; } for(int j=n-i-2;j>i&&t<=n*n;j--){ a[j][i]=j+ +; } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ printf("%4d",a[i][j]); } } return 0; }
Main.cc: In function 'int main()': Main.cc:9:17: error: array must be initialized with a brace-enclosed initializer int a[21][21]=(0); ^ Main.cc:20:32: error: expected ';' before ')' token for(int j=n-i-2&&t<=n*n;j--){ ^ Main.cc:24:21: error: expected primary-expression before ';' token a[j][i]=j+ +; ^