public static void main(String[] args) {
// TODO Auto-generated method stub
int triangle[][]=new int[8][]; //定义长度
for(int i=0;i<triangle.length;i++){
triangle[i]=new int[i+1]; //初始化
for(int j=0;j<triangle[i].length;j++){
}else{
triangle[i][j]=triangle[i-1][j-1]+triangle[i-1][j];
}
System.out.print(triangle[i][j]+"\t");
}
System.out.println();
}
System.out.println();
}
// TODO Auto-generated method stub
int triangle[][]=new int[8][]; //定义长度
for(int i=0;i<triangle.length;i++){
triangle[i]=new int[i+1]; //初始化
for(int j=0;j<triangle[i].length;j++){
if(i==0||j==0||j==triangle[i].length-1){ //理解j==triangle[i].length-1,若没有该条件。就会执行else语句,由于没有triangle[i-1][j]对应的数值。所以会报错
triangle[i][j]=1;}else{
triangle[i][j]=triangle[i-1][j-1]+triangle[i-1][j];
}
System.out.print(triangle[i][j]+"\t");
}
System.out.println();
}
System.out.println();
}