T1代码
#include <bits/stdc++.h>
using namespace std;
const int N = 210;
int n;
int a[N][N];
int main() {
cin >> n;
for (int i = 0; i < n; i ++ )
for (int j = 0; j < n; j ++ ) {
if (i == j || i + j == n - 1 || (n & 1) && (i == n >> 1 || j == n >> 1)) continue;
else {
if (i < n >> 1) {
if (j < n >> 1) {
if (i > j) a[i][j] = 3;
else a[i][j] = 2;
} else {
if (i + j >= n) a[i][j] = 8;
else a[i][j] = 1;
}
} else {
if (j < n >> 1) {
if (i + j >= n) a[i][j] = 5;
else a[i][j] = 4;
} else {
if (i > j) a[i][j] = 6;
else a[i][j] = 7;
}
}
}
}
for (int i = 0; i < n; i ++ ) {
for (int j = 0; j < n; j ++ ) cout << a[i][j] << ' ';
puts("");
}
return 0;
}
gg