问题描述
Java 代码实现
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[][] a = new int[n+5][n+5];
a[1][1] = 1;
System.out.println(a[1][1]);
for (int i = 2; i <= n; ++i) {
for (int j = 1; j <= i; ++j) {
a[i][j] = a[i-1][j] + a[i-1][j-1];
System.out.printf("%d ", a[i][j]);
}
System.out.println();
}
in.close();
}
}