#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
int a[n][n];
memset(a, 0, sizeof(a));
a[n - 1][n / 2] = 1;
int k = 2;
int x = n - 1, y = n / 2;
while(k <= n * n)
{
if(x == n - 1)
x = 0;
else
x++;
if(y == 0)
y = n - 1;
else
y--;
if(a[x][y] == 0)
a[x][y] = k++;
else
{
if(x == 0)
x = n - 1;
else
x--;
if(y == n - 1)
y = 0;
else
y++;
if(x == 0)
x = n - 1;
else
x--;
a[x][y] = k++;
}
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
cout << a[i][j] << " ";
cout << endl;
}
}
return 0;
}
题目不是给hint了吗
来人把她拖出去(老实人孤立她……