Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
139485 | 杨博煊 | 回型方阵 | C++ | 通过 | 100 | 0 MS | 244 KB | 448 | 2024-03-23 17:28:23 |
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 1][n + 1]; int x = (n + 1) / 2; for(int k = 1;k <= x;k++) { for(int i = x + 1 - k;i <= n - x + k;i++) { int t = x - k + 1; a[n - x + k][i] = t; a[i][n - x + k] = t; a[x + 1 - k][i] = t; a[i][x + 1 - k] = t; } } for(int i = 1;i <= n;i++) { for(int j = 1;j <= n;j++) { cout << setw(5) << a[i][j]; } cout << endl; } }