import java.util.Scanner;
class Demo{
public static void main(String[] args){
System.out.println("请输入九宫格的行列规模(只能是奇数的)");
Scanner n = new Scanner(System.in);
int N;
double d;
while (true){
d = n.nextDouble();
N = (int)d;
if ((d-N)>1.0E-4||N%2==0||N<0)
{System.out.println("输入出错,格局只能是正奇数。请重新输入");}
else break;
}
int[][] result = new int[N][N];
int row = 0;
int col = N/2;
for (int i=1; i<=N*N; i++){
result [row][col] = i;
row--;
col++;
if (row<0&&col>=N){col--;row+=2;}
else if (row<0){ row = N-1;}
else if (col>=N){col = 0;}
else if (result[row][col] != 0){col--;row+=2;}
}