求帮助。
#include<bits/stdc++.h>
using namespace std;
int a[39][39];
int main(){
int n;
cin >> n;
int x = n / 2, y = 0, p = 1, t = n * n;
a[x][y] = p;
while(p <= t){
x++; y--;
if(x == n && y < 0){
x--; y += 2;
}
else if(x == n) x = 0;
else if(y < 0) y = n - 1;
else if(a[x][y]){
x--; y += 2;
}
a[x][y] = ++p;
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cout << a[j][i] << ' ';
}
cout << endl;
}
return 0;
}