把代码给你打出来了,你自己看下吧
public class yangHui {
public static void main(String[] args) {
daYin(9);
}
public static void daYin(int x) {
int[][] arr = new int[x][x];
for(int i = 0; i < x; i++) {
arr[i][0] = 1;
for(int j = 1; j < i + 1; j++) {
arr[i][j] = arr[i - 1][j - 1] + arr[i -1][j];
}
}
for (int i = 0; i < x; i++) {
for(int j = 0; j < i + 1; j++) {
System.out.print(arr[i][j] + "\t");
}
System.out.println();
}
}
} |