Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
39656 | -若只- | 健康身材(health)(2024年岳阳市赛小学组) | C++ | 输出超限 | 0 MS | 324 KB | 544 | 2024-05-05 09:06:03 |
#include<bits/stdc++.h> using namespace std; int n,s[105][105],x,y,t; int main(){ cin>>n; x=1; y=n; t=n*n; s[x][y]=t; t--; while(t){ while(x+1<=n&&s[x+1][y]==0){ x++; s[x][y]=t; t--; } while(y-1>0&&s[x][y-1]==0){ y--; s[x][y]=t; t--; } while(x-1>0&&s[x-1][y]==0){ x--; s[x][y]=t; t--; } while(y+1<=n&&s[x][y+1]==0){ y++; s[x][y]=t; t--; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<s[x][y]<<" "; }cout<<endl; } return 0; }