#include<iostream>
using namespace std;
int main()
{
int k,a[100][100],m=1,n=1,s,x;
a[1][0]=1;
cout<<"请输入要打印的杨辉三角的行数:"<<endl;
cin>>k;
for(int i=0;i<=(k-1);i++)
a[0][i]=1;
cout<<"1"<<endl;
cout<<"1 1"<<endl;
for(int y=3;y<=k;y++)
{
x=1;
cout<<"1"<<" ";
while(x<(y-1))
{
s=0;
for(int j=0;j<=n;j++)
s=s+a[m-1][j];
a[m][n]=s;
x++;
cout<<a[m][n]<<" ";
m++;
n--;
if(n==0)
a[m][n]=1;
}
cout<<"1"<<endl;
m=1;
n=y-1;
}
return 0;
}