You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
633 B

#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;
}