100 Accepted
# | 状态 分数 | 耗时 | 内存占用 |
---|---|---|---|
#1 | Accepted 10 | 3ms | 536 KiB |
#2 | Accepted 10 | 3ms | 536 KiB |
#3 | Accepted 10 | 2ms | 536 KiB |
#4 | Accepted 10 | 3ms | 536 KiB |
#5 | Accepted 10 | 3ms | 328 KiB |
#6 | Accepted 10 | 3ms | 548 KiB |
#7 | Accepted 10 | 3ms | 764 KiB |
#8 | Accepted 10 | 3ms | 764 KiB |
#9 | Accepted 10 | 2ms | 324 KiB |
#10 | Accepted 10 | 3ms | 324 KiB |
代码
#include<iostream>
#include<iomanip>
using namespace std;
const int N = 25;
int a[N][N];
int main(){
int n,x,y,k;
cin>>n;
x=n,y=0,k=0; //笔初始坐标
for (int i=1; i<=n; i++){
while (y+1<=i) a[x][++y]=++k;
while (x+1<=n) a[++x][y]=++k;
x=n-i; y=0; //每次迂回完,重置笔坐标
}
for (int i=1; i<=n; i++){
for (int j=1; j<=n; j++) cout<<setw(4)<<a[i][j];
cout<<endl;
}
return 0;
}
信息
- 递交者
- 题目
- P369 练63.3 迂回方阵
- 语言
- C++11
- 代码长度
- 377 Bytes
- 递交时间
- 2024-11-10 17:16:14
- 评测时间
- 2024-11-10 17:16:15
- 分数
- 100
- 总耗时
- 26ms
- 峰值时间
- 3ms
- 峰值内存
- 764 KiB