#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
int main()
{
ll maxn, n, k;
cout << "Enter Row Number :: ";
cin >> maxn;
ll c[maxn+1][maxn+1];
c[0][0] = 1;
for(n=1;n<=maxn;n++)
{
c[n][0] = c[n][n] = 1;
for(k=1;k<n;k++)
c[n][k] = c[n-1][k-1] + c[n-1][k];
}
cout << "Binomial Coefficient is :: " << endl;
for(n=0;n<=maxn;n++)
{
for(ll s=1;s<=maxn-n;s++)
cout <<" ";
for(ll i=0;i<=n;i++)
cout << c[n][i] << " ";
cout << endl;
}
return 0;
}
#define ll unsigned long long int
using namespace std;
int main()
{
ll maxn, n, k;
cout << "Enter Row Number :: ";
cin >> maxn;
ll c[maxn+1][maxn+1];
c[0][0] = 1;
for(n=1;n<=maxn;n++)
{
c[n][0] = c[n][n] = 1;
for(k=1;k<n;k++)
c[n][k] = c[n-1][k-1] + c[n-1][k];
}
cout << "Binomial Coefficient is :: " << endl;
for(n=0;n<=maxn;n++)
{
for(ll s=1;s<=maxn-n;s++)
cout <<" ";
for(ll i=0;i<=n;i++)
cout << c[n][i] << " ";
cout << endl;
}
return 0;
}
Comments
Post a Comment