C语言:排列组合

排列组合:数学公式求解
数学公式:排列组合

#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
*/

猜你喜欢

转载自blog.csdn.net/qq_39004632/article/details/84582325