C++调用 递归函数求阶乘

2024-12-23 12:38:32
推荐回答(1个)
回答1:

int fac(int n);//这个后面的分号去掉啊

#include
int main()
{
int fac(int n);
int n;
int y;
scanf("%d",&n);
y=fac(n);
printf("%d%d",n,y);
return 0;
}
int fac(int n)//!!!!!!!!!!!!!!!!!!!!!
{
int f;
if(n<0)
printf("date error");
else
if(n==1)
f=1;
else
f=fac(n-1)*n;
return(f);
}