#include <bits/stdc++.h>
using namespace std;
int n;
int a[100][100];
int main() {
cin >> n;
a[1][1] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (j == 1 || j == i) a[i][j] = 1;
else a[i][j] = a[i - 1][j - 1] + a[i - 1][j - 1];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++) cout << " ";//居中代码
for (int j = 1; j <= i; j++) {
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
09-26
533
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)