//ncr ..n combination r!
#include <iostream>
#include <conio>
int show( int n)
{ int c;
c=1;
if(n==0)
return 1;
else
{
while(n>1)
{
c=c*n;n--;
}
}
return c;}
void main()
{ while(1)
{
int a,r,d,e,f,g;
cout<<"\tenter n:\t";
cin>>a;
cout<<endl;
cout<<"\tenter r:\t:";
cin>>r;
d=show(a);
e=show(r);
f=a-r;
g=show(f);
int h=(d)/(g*e);
cout<<endl;
cout<<"\tcombination:\t"<<h<<endl;
}
getch();
}
0 comments:
Post a Comment