杨辉三角形_wdl

package com.wdl.day07;

/**
* @创建人 wdl
* @创建时间 2021/8/8
* @描述
*/
public class YangHuiTest {
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];
yanghui[i][0] = 1;
yanghui[i][i] = 1;
for (int j = 1; j < i; j++) {
yanghui[i][j] = yanghui[i - 1][j] + yanghui[i - 1][j - 1];
}
}

for (int[] ints : yanghui) {
for (int anInt : ints) {
System.out.print(anInt + " ");
}
System.out.println();
}
}
}