1 public class YangHui{
2 public static void main(String [] args){
3 Scanner scan = new Scanner(System.in);
4 int n = scan.nextInt(); //扫描器(需先导入Scanner包
5 int [][] a = new int[n][n]; //创建int型二维数组
6 for(int i=0;i<n;i++){ //遍历
7 for(int j=0;j<=i;j++){
8 if(j==0|j==i){ //边
9 a[i][j]=1;
10 }
11 else{
12 a[i][j]=a[i-1][j]+a[i-1][j-1]; //边以内
13 }
14 }
15 }
16 Object[][] obj = new Object[n][2*n]; //创建数组
17 for(int i = 0;i<n;i++){ //遍历
18 for(int j = 0;j<2*n;j++){
19 if(j==n-i|j==n+i){ //边
20 obj[i][j] = 1;
21 System.out.print(obj[i][j]+" ");
22 }
23 else if(j>n-i&j<n+i&(j-n+i)%2==0){ //边以内每隔一个输出一个非空格
24
25 obj[i][j]=a[i][(j-n+i)/2]; //把a数组套入obj内
26 System.out.print(obj[i][j]+" ");
27
28 }
29 else{
30 obj[i][j] =" "; //空白部分
31 System.out.print(obj[i][j]+" ");
32 }
33 }
34 System.out.println();
35 }
36 }
37 }