Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
8041 | 詹梓涵 | 螺旋矩阵 | C++ | Runtime Error | 3 MS | 256 KB | 632 | 2025-06-07 10:44:15 |
#include<bits/stdc++.h> using namespace std; int main(){ int a[11][11]; int n,x=1; cin>>n; int k= n%2==1 ? n/2+1 : n/2 ; for(int z=1;z<=k;z++){ for(int j=z;j<=n-z+1;j++){ a[z][j]=x++; } for(int i=z+1;i<=n-z+1;i++){ a[i][n-z+1]=x++; } for(int j=n-z;j>=z;j--){ a[n-z+1][j]=x++; } for(int i=n-z;i>=z+1;i--){ a[i][z]=x++; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(4)<<a[i][j]; } cout<<endl; } return 0; }
Runtime Error:Segmentation fault