实验五-函数2

#include<stdio.h>
int main(void)
{
    int m,n;
    float result,sum;
    float fact(int n);
    printf("enter m and n:");
    scanf("%d %d",&m,&n);
    sum=fact(m-n);
    result=fact(m)/(fact(n)*sum);
    printf("result=%.0f\n",result);
    return 0;
}
float fact(int n)
{
    int i;
    float result;
    result=1;
    for(i=1;i<=n;i++){
        result=result*i;
    }
    return result;
}

 

posted @ 2013-10-21 19:23  红颜文丛  阅读(133)  评论(1编辑  收藏  举报