在下列程序中,fun函数的功能是用递归的方式求n的阶乘。
在主函数中输入n,然后调用fun函数求出n的阶乘并输出。
请将空缺的代码填写完整。
#include<stdio.h>
double fun(int n)
{
double f;
if (n==0 || n==1)
f =
1
;
else
f = n *
fun(n-1)
;
return f;
}
int main( )
{
int n;
double f;
scanf("%d", &n);
f =
fun(n)
;
printf("%.0f", f);
return 0;
}