| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 158308 | 郦辰希 | 方阵填数 | C++ | Accepted | 1 MS | 284 KB | 736 | 2026-08-20 18:04:40 |
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin>>N; int n=1,t=0,b=N-1,l=0,r=N-1; int a[101][101]; while(n<=N*N){ for(int i=t;i<=b && n<=N*N;i++){ a[i][r]=n; n++; } r--; for(int i=r;i>=l && n<=N*N;i--){ a[b][i]=n; n++; } b--; for(int i=b;i>=t && n<=N*N;i--){ a[i][l]=n; n++; } l++; for(int i=l;i<=r && n<=N*N;i++){ a[t][i]=n; n++; } t++; } for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ cout<<a[i][j]<<" "; } cout<<endl; } }