Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
8054 | 吴承熹 | 螺旋矩阵 | C++ | Wrong Answer | 0 MS | 264 KB | 848 | 2025-06-08 10:45:09 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<iomanip> #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int a[21][21]={}; int n,c=1; cin>>n; int k= n%2==0 ? n/2+1 : n/2; for(int z=1;z<=k;z++){ for(int j=z;j<=n-z+1;j++){ a[z][j]=c++; } for(int i=z+1;i<=n-z+1;i++){ a[i][n-z+1]=c++; } for(int j=n-z;j>=z;j--){ a[n-z+1][j]=c++; } for(int i=n-z;i>=z+1;i--){ a[i][z]=c++; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(4)<<a[i][j]; } cout<<endl; } return 0; }//
------Input------
1
------Answer-----
1
------Your output-----
0