Run ID:129024
提交时间:2025-08-21 15:32:23
#include<bits/stdc++.h> using namespace std; int main() { long long a[31][31] = {}; a[1][1] = 1; int n; cin >> n; for(int i = 2; i <= 30; i++) { for(int j = 1; j <= i; 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 = 2; i <= n + 1; i++) { if(a[n + 1][i + 1] != 0) { cout << a[n + 1][i] << " "; } else { cout << a[n + 1][i]; } } return 0; }