#include <iostream>
using namespace std;
int fact(int n)
{
int a=1;
for (int i=1;i<=n;i++)
{
a=a*i;
}
return a;
}
int main()
{
int p;
cout<<"Enter number of rows";
cin>>p;
for(int j=0;j<p;j++)
{
for(int c=0;c<=(p-j-2);c++)
{
cout<<" ";
}
for (int c=0;c<=j;c++)
{
cout<<fact(j)/(fact(c)*fact(j-c))<<" ";
}
cout<<endl;
}
return 0;
}
output:
Enter number of rows 7
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
0 Comments
Post a Comment