#include <iostream>
using namespace std;
int fac(int x);
int main()
{
int a[30][30],n;
int i,j;
cin>>n;
for(i=0; i<n; i++)
{
a[i][0]=1;
a[i][i]=1;
}
for(i=2; i<n; i++)
for(j=1; j<i; j++)
{
a[i][j]=fac(i)/(fac(j)*fac(i-j));
}
for(i=0; i<n; i++)
{
for(j=0; j<i; j++)
{
cout<<a[i][j]<<" ";
}
cout<<a[i][i]<<endl;
}
return 0;
}
int fac(int x)
{
int s;
if(x==1||x==0)
s=x;
else
{
s=fac(x-1)*x;
return s;
}
}<img src="https://img-blog.csdn.net/20141209171346833?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemh5NzE3NDUyMzgz/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
杨辉三角
最新推荐文章于 2024-03-19 23:06:37 发布