#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define MAX 45
int main()
{
int n, x, y, num, i, j;
scanf("%d", &n);
if (n == 1){
printf("1");
return 0;
}
x = 1;
y = (n + 1)/2;
int arr[MAX][MAX] = {0};
for ( num = 1; num <= n*n; num++){
arr[x][y] = num;
if (! arr[(x - 2 + n)%n + 1][y%n + 1]) x = (x - 2 + n)%n + 1, y = y%n + 1;
else x = x%n + 1;
}
for ( i = 1; i <= n; i++){
for ( j = 1; j <= n; j++)
printf("%d ", arr[i][j]);
printf("\n");
}
return 0;
}
**题目的意思就是从第一行中点开始,把每一个下面的数
放到“右上角”,若右上角有数,则放到正下方。**