#include<bits/stdc++.h>
#define N 10000
using namespace std;
int a[N][N];
void ncr(int n)
{
int i, j;
a[0][0] = 1;
for(i=1;i<=n;i++)
{
for(j=0;j<=n;j++)
{
if(j > i)
a[i][j] = 0;
else if(j == i || j == 0)
a[i][j] = 1;
else
a[i][j] = a[i-1][j-1] + a[i-1][j];
}
}
}
int main()
{
int n, i, j;
cout << "Enter Any Number :: ";
cin >> n;
ncr(n);
cout << 0 << " To " << n << " Combination are :: " << endl;
for(i=0;i<=n;i++)
{
for(j=0;j<=n;j++)
{
cout <<"C" << "(" << i << "," << j << ")" << " = " << a[i][j] << endl;
}
cout << endl;
}
return 0;
}
#define N 10000
using namespace std;
int a[N][N];
void ncr(int n)
{
int i, j;
a[0][0] = 1;
for(i=1;i<=n;i++)
{
for(j=0;j<=n;j++)
{
if(j > i)
a[i][j] = 0;
else if(j == i || j == 0)
a[i][j] = 1;
else
a[i][j] = a[i-1][j-1] + a[i-1][j];
}
}
}
int main()
{
int n, i, j;
cout << "Enter Any Number :: ";
cin >> n;
ncr(n);
cout << 0 << " To " << n << " Combination are :: " << endl;
for(i=0;i<=n;i++)
{
for(j=0;j<=n;j++)
{
cout <<"C" << "(" << i << "," << j << ")" << " = " << a[i][j] << endl;
}
cout << endl;
}
return 0;
}
Comments
Post a Comment