| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 160308 | 格林老师 | 方阵填数 | C++ | Presentation Error | 1 MS | 280 KB | 863 | 2026-09-14 21:35:42 |
#include <bits/stdc++.h> using namespace std; int a[101][101]; int main() { int n; cin>>n; int bottom=n,top=1,right=n,left=1; int num=1; while (num<=n*n){ for (int j=top;j<=bottom && num<=n*n;j++){ a[j][right]=num; num++; } right--; for (int j=right;j>=left && num<=n*n;j--){ a[bottom][j]=num; num++; } bottom--; for (int j=bottom;j>=top && num<=n*n;j--){ a[j][left]=num; num++; } left++; for (int j=left;j<=right && num<=n*n;j++){ a[top][j]=num; num++; } top++; } for (int i=1;i<=n;i++){ for (int j=1;j<=n;j++){ cout<<a[i][j]<<" "; } cout<<'\n'; } return 0; }