| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 3835 | 龚施宇 | 螺旋矩阵 | C++ | Accepted | 100 | 0 MS | 264 KB | 518 | 2019-12-22 18:47:35 |
#include<iostream> using namespace std; int main(){ int n,a[101][101],k=1; cin>>n; int quan=(n+1)/2; for(int i=1;i<=quan;i++){ for(int j=i;j<=n+1-i;j++){ a[i][j]=k++; } for(int j=i+1;j<=n+1-i;j++){ a[j][n+1-i]=k++; } for(int j=n+1-i-1;j>=i;j--){ a[n+1-i][j]=k++; } for(int j=n+1-i-1;j>=i+1;j--){ a[j][i]=k++; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<a[i][j]; if(j!=n) cout<<" "; } if(i!=n) cout<<endl; } return 0; }