package arr0210;
public class YangHuiSanJiao {
public static void main(String[] args) {
int[][] number=new int[30][];
for(int i=0;i<number.length;i++) {
number[i]=new int[i+1];
number[i][0]=number[i][i]=1;
for(int j=1;j<number[i].length-1;j++) {
number[i][j]=number[i-1][j]+number[i-1][j-1];
}
for(int k=0;k<number.length-i;k++) {
System.out.print(" ");
}
for(int j=0;j<number[i].length;j++) {
System.out.print(number[i][j]+" ");
}
System.out.println();
}
}
}
JAVA实现杨辉三角
最新推荐文章于 2024-11-15 18:38:47 发布