class Demo
{
public static void main(String[] args)
{
int n = 9;
int[][] arr = new int[n][n];
for(int i = 0;i < arr.length ; i++){
for(int j = 0; j < arr.length ; j++){
if(j == 0 || j == i){
arr[j] = 1;
}else{
arr[j] = arr[i - 1][j] + arr[i - 1][j - 1];
}
}
}
for(int i = 0; i < arr.length ; i++){
for(int j = 0; j <= i ; j++){
System.out.print(arr[j] + "\t");
}
System.out.println();
}
}
}
求大神看看函数有数组越界吗
|
|