实验5(2)编制程序,输入m、n(m≥n≥0)后,计算下列表达式的值并输出。 要求将计算阶乘的运算编写作函数fact(n),函数返回值的类型为float

#include<stdio.h>
double fact(int n);
int main(void)
{
    int m,n;
    double y,x;
    printf("Enter n:");
    scanf_s("%d",&n);
    printf("Enter m:");
    scanf_s("%d",&m);

    x=fact(n)*fact(m-n);
    y=fact(m)/x;
    printf("result=%.0f
",y);
    
    return 0;
}

double fact(int n)
{
    int i;
    double product;
    product=1;
    for(i=1;i<=n;i++){
        product=product*i;
    }

        return product;
    }

原文地址:https://www.cnblogs.com/blgl/p/3379963.html