排列组合:数学公式求解
#include<stdio.h>
double Count(int n);
int main()
{
int n,m;
double Above,Below,x;
double Count(int n);
printf("Enter n and m(m<=n):\n");
scanf("%d,%d",&n,&m);
Above=Count(n);
Below=Count(m);
x=Count(n-m);
printf("%0.1f\n",Above/(Below*x));
}
double Count(int n)//求阶乘
{
int i;
double sum;
sum=1;
for(i=1;i<=n;i++)
{
sum=sum*i;
}
return sum;
}
/*
(样例输入)
Enter n and m(m<=n):
5 3
10.0
*/