//2032杨辉三角
#include<iostream>
using namespace std;
const int N = 100;
int a[N][N];
void func(int n)
{
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; j++)
{
if (j == 1)
a[i][j] = 1;
a[i + 1][j + 1] = a[i][j] + a[i][j + 1];
cout << a[i][j] << ' ';
}
cout << endl;
}
cout << endl;
}
int main()
{
int n;
while (cin >> n)
{
func(n);
}
return 0;
}
hdu 32 杨辉三角
最新推荐文章于 2024-09-01 16:42:17 发布