import java.util.Scanner; public class fourth { public static void main(String[] args) { System.out.println("请输入中心数:"); Scanner scanner=new Scanner(System.in); int row=scanner.nextInt(); int [][] arr=new int [2*row-1][2*row-1]; for(int i=0;i<row;i++){ for(int j=0;j<row;j++){ arr[i][j]=i+1; } } for(int a=1;a<row;a++){ int t=1; for(int b=0;b<a;b++){ arr[a][b]=t;t++; } } for(int i=0;i<row;i++){ int head=0; int end=2*row-2; do{ arr[i][end]=arr[i][head]; end--; head++; }while (end>=row); }int t=0; for(int i=2*row-1;i>=row;i--){ for(int a=0;a<2*row-1;a++){ arr[i-1][a]=arr[t][a]; } t++; if(t==row)break; } for(int i=0;i<arr.length;i++){ for(int q=0;q<arr.length;q++){ System.out.print(arr[i][q]+" "); } System.out.println(); } } } 请输入中心数: 4 1 1 1 1 1 1 1 1 2 2 2 2 2 1 1 2 3 3 3 2 1 1 2 3 4 3 2 1 1 2 3 3 3 2 1 1 2 2 2 2 2 1 1 1 1 1 1 1 1