c语言作业,编写程序:计算m!n!/(m-n)!,其中m、n为正整数且m>n_百度知...
发布网友
发布时间:2024-10-03 02:09
我来回答
共2个回答
热心网友
时间:2024-10-06 08:26
#include "stdio.h"
long jiecheng(n)
{
int i;
long x=1;
for(i=1;i<=n;i++)
x=x*i;
}
void main()
{
int m,n;
printf("m=");
scanf("%d",&m);
printf("n=");
scanf("%d",&n);
if(m<=n)
printf("error\n");
else
printf("%f\n",jiecheng(m)*jiecheng(n)*1.0/jiecheng(m-n));
}
热心网友
时间:2024-10-06 08:21
#include<stdio.h>
long fun(long a);
void main()
{
long m,n;
printf("please input the 'm'\n");
scanf("%ld",&m);
printf("please input the 'n'\n");
scanf("%ld",&n);
printf("result=%ld\n",fun(m)*fun(n)/fun(m-n));
}
long fun(long a)
{
long result=1;
while(a)
result*=a--;
return result;
}