Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
while (n != 0)
{
for (int i = 1; i <= n; i ++)
{
for (int j = 1; j <= n; j ++)
System.out.print (Math.min(Math.min(i, n+1-i), Math.min(j, n+1-j)) + " ");
System.out.print("\n");
}
System.out.println("");
n = cin.nextInt();
}
}
}