#include <iostream>
using namespace std;
int main()
{
int i,j;
int n;
cin >> n;
int a[34][34] = {1};
for (i = 1;i < n;i ++)
{
a[i][0] = 1;
a[i][i] = 1;
for (j = 1;j < i;j++)
{
a[i][j] = a[i-1][j-1] + a[i-1][j];
}
}
for (i = 0;i < n;i ++)
{
for (j = 0;j <= i;j ++)
{
cout << a[i][j] <<" ";
}
cout << endl;
}
system("pause");
return 0;
}
杨辉三角
最新推荐文章于 2024-03-17 18:00:07 发布