java趣味题-打印杨辉三角
public class First105 {
public static void main(String[] args) { int [][] a=new int[9][9] ; a[0][0]=1; a[1][0]=1; a[1][1]=1; for(int i=2;i<9;i++){ a[i][0]=1; a[i][i]=1; for(int j=1;j<i;j++){
a[i][j]=a[i-1][j-1]+a[i-1][j]; //System.out.println(a[i][j]); } }
for(int q=0;q<9;q++){ for(int w=0;w<=q;w++){ System.out.print(a[q][w]+" "); }System.out.println(); } }
}
posted on
2018-03-10 14:03
张仙人 阅读(
...) 评论(
)
编辑
收藏
转载于:https://www.cnblogs.com/zhangxianren/p/8539006.html