`
public class YanghuiTest3 {
public static void main(String[] args) {
//动态初始化一个10行的二维数组
int[][] yh = new int[10][];
for (int i = 0; i < yh.length; i++) {
yh[i] = new int[i +1];
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i) {
yh[i][j] = 1;
}else {
yh[i][j] = yh[i -1][j-1] + yh[i -1][j];
}
System.out.print(yh[i][j] + " ");
}
//上面一行遍历打印完后,就换行打印下一行
System.out.println();
}
}
}
`