使用二维数组完成:要求使用循环。
1 0 0 0 0
1 1 0 0 0
1 2 1 0 0
1 3 3 1 0
1 4 6 4 1
public class D{
public static void main(String[] args){
int[][] a=new int[5][5];
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
if(j==0||i==j){
a[i][j]=1;
}
if(i>j&&j!=0){
a[i][j]=a[i-1][j]+a[i-1][j-1];
}
}
}
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
System.out.print(a[i][j]);
}
System.out.println();
}
}
}