#include <iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main()
{
int n;
while (cin >> n)
{
vector<int>a = {1,1};
vector<int>b = {1,1};
if (n == 1)
cout << "1" << endl;
if (n == 2)
{
cout << "1" << endl;
cout << "1 1" << endl;
}
if (n >= 3)
{
cout << "1" << endl;
cout << "1 1" << endl;
for (int m=3;m<n+1;m++)
{
for (int i = 0; i < m-1; i++)
{
if (i == 0)
b[i] = 1;
else
b[i] = a[i - 1] + a[i];
}
b.push_back(1);
a.push_back(1);
for (int i = 0; i < b.size(); i++)
{
a[i] = b[i];
}
for (int i = 0; i < a.size(); i++)
{
cout << a[i];
if (i != a.size() - 1)
cout << " ";
}
cout << endl;
}
}
cout << endl;
}
return 0;
}
小熊崽纸的杭电2032杨辉三角
最新推荐文章于 2021-05-23 06:00:22 发布