| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 85847 | 梁敖铭 | 螺旋矩阵 | C++ | Compile Error | 0 MS | 0 KB | 458 | 2024-07-20 20:47:08 |
include<iostream> 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;j>=i&&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]=t++; i++; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++) printf("%4d",a[i][j]); cout<<endl; } return 0; }
Main.cc:1:1: error: 'include' does not name a type include ^ Main.cc: In function 'int main()': Main.cc:6:1: error: 'cin' was not declared in this scope cin>>n; ^ Main.cc:17:43: error: 'printf' was not declared in this scope for(int j=0;j