Run ID:129000

提交时间:2025-08-21 15:14:22

#include<bits/stdc++.h> using namespace std; int main() { int a[31][31] = {}; a[1][1] = 1; int n; cin >> n; for(int i = 2; i <= 30; i++) { for(int j = 2; j <= 30; j++) { a[i][j] = a[i - 1][j] + a[i - 1][j - 1]; } } for(int i = 2; i <= n; i++) { for(int j = 2; j <= n; j++) { if(a[i][j] != 0) { if(a[i][j + 1] != 0) { cout << a[i][j] << " "; } else { cout << a[i][j]; } } } cout << endl; } for(int i = 1; i <= n + 1; i++) { if(a[n + 1][i + 1] != 0) { cout << a[n + 1][i] << " "; } else { cout << a[n + 1][i]; } } return 0; }