c++请哥哥姐姐帮下我

来源:百度知道 编辑:UC知道 时间:2024/06/25 10:16:03
用调用函数求(m+n)!/m!+n!

你是要(m+n)!/m!+n!还是(m+n)!/(m!+n!)

#include <stdio.h>

int jie(int n);
int get(int a,int b);

void main()
{
int m,n,sun;
printf("please input m:");
scanf("%d",&m);
printf("please input n:");
scanf("%d",&n);

sun=get(m,n);

printf("the sum is:%d\n",sun);
}

int jie(int n)
{
int sun=1;
int i;
for(i=1;i<=n;i++)
{
sun=sun*i;
}
return sun;
}

int get(int a,int b)
{
int temp;
temp=jie(a+b)/jie(a)+jie(b);
return temp;
}

jie()函数是就阶层,get()是计算(m+n)!/m!+n!,其中调用了jie()来就阶层