Files
python/TangDou/LianXiTi50/33.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

28 lines
633 B
C++

#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N][N];
int main() {
int n = 10;
for (int i = 1; i <= n; i++) {
a[i][1] = 1;
a[i][i] = 1;
}
//填充内容
for (int i = 3; i <= n; i++)
for (int j = 2; j < i; j++)
a[i][j] = a[i - 1][j] + a[i - 1][j - 1];
//控制格式输出
for (int i = 1; i <= n; ++i) {
//控制空格数量
for(int j=0;j<=n-i;j++) cout<<" ";
for (int j = 1; j <= n; ++j) {
if (a[i][j]) printf("%d ",a[i][j]);
}
cout << endl;
}
return 0;
}