Files
python/TangDou/LuoGuBook/P5732.cpp

23 lines
529 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
const int N = 25;
int a[N][N];
int n;
int main() {
cin >> n;
//遍历每一行
for (int i = 0; i <= n - 1; i++) {
//遍历每一列
for (int j = 0; j <= i; j++) {
//第一列,最后一列都是1
if (j == 0 || j == i) a[i][j] = 1;
//递推式
else a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
printf("%d ", a[i][j]);
}
printf("\n");
}
return 0;
}