【java练习题33】--打印出杨辉三角形

ublic static void main(String[] args) {
// TODO Auto-generated method stub
int ss[][]=new int[10][10];
for (int i = 0; i < ss.length; i++) {
ss[i][0]=1;
ss[i][i]=1;
}
for (int i = 2; i <10; i++) {
for (int j = 1; j <=i-1; j++) {
ss[i][j]=ss[i-1][j]+ss[i-1][j-1];
}
}

for (int i = 0; i < ss.length; i++) {
for (int j = 0; j <=i; j++) {
System.out.print(" "+ss[i][j]);
}
System.out.println();
}
}

你可能感兴趣的:(java练习题)