二维数组小练习 打印 杨辉三角

`
public class YanghuiTest {
public static void main(String[] args) {
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;
}

            if(i>=2 && 0<j && j<i){
                yh[i][j] = yh[i-1][j-1]+yh[i-1][j];
            }

            System.out.print(yh[i][j]+"	");
            if(i==j){
                System.out.println();
            }
        }
    }
}

}
`

原文地址:https://www.cnblogs.com/zui-ai-java/p/14182277.html