import java.util.Scanner;
public class Main06 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[][] arr = new int[34][34];
for (int i = 0; i < arr.length; i++){
arr[i][0] = 1;
}
for (int i = 1; i < arr.length; i++) {
for (int j = 1; j < 34; j++) {
arr[i][j] = arr[i-1][j-1] + arr[i-1][j];
}
}
int n = scanner.nextInt();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (arr[i][j] != 0) {
System.out.print(arr[i][j] + " ");
}
}
System.out.println();
}
}
}
比较基础,还有更好的算法的话希望大佬分享。