package com.alhh.java;
public class TestyangHui {
public static void main(String[] args){
int[][] yangHui=new int[10][];
//初始化二维数组
for(int i=0;i<yangHui.length;i++){
yangHui[i]=new int[i + 1];//每行对应的元素,第i行对应第i+1个元素
}
//赋值
for(int i=0;i<yangHui.length;i++){
for(int j=0;j<yangHui[i].length;j++){
yangHui[i][0]=yangHui[i][i]=1;
if(i>1&&j<i&&j>0){
yangHui[i][j]=yangHui[i-1][j]+yangHui[i-1][j-1];
}
}
}
//遍历二维数组
for(int i=0;i<yangHui.length;i++){
for(int j=0;j<yangHui[i].length;j++){
System.out.print(yangHui[i][j]+" ");
}
System.out.println();
}
}
}