B3940,很奇怪的错误
#include <bits/stdc++.h>
using namespace std;
int a[50][50];
int main() {
int n, x, y, cnt = 2;
cin >> n;
x = 1;
y = n / 2 + 1;
a[x][y] = 1;
for (int i = 1; i < n * n; ++i) {
if (x == 1) {
x = n;
} else {
x--;
}
if (y == n) {
y = 1;
} else {
y++;
}
if (a[x][y] == 0) {
a[x][y] = cnt;
cnt++;
} else {
if (x == n) {
x = 1;
} else {
x++;
}
a[x][y] = cnt;
cnt++;
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}