刚开始也没看到hint
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int nums[100][100];
int main() {
int n;
while (cin >> n) {
memset(nums, 0, sizeof(nums));
int x = n;
int y = n / 2 + 1;
int v = 1;
while (v <= n * n) {
nums[x][y] = v++;
++x;
--y;
if (x > n) {
x = 1;
}
if (y < 1) {
y = n;
}
if (nums[x][y] != 0) {
x -= 2;
y += 1;
if (x < 1 && y > n) {
x = n - 1;
y = 1;
}
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
printf("%d%c", nums[i][j], j < n ? ' ' : '\n');
}
}
}
return 0;
}
题目不是给hint了吗
来人把她拖出去(老实人孤立她……