高仿模拟练习,补全 found 标记处空缺,答案点击按钮展开
编写fun函数计算n的阶乘,公式为n!=1×2×…×n,请补全程序。
#include <stdio.h>
long long fun(int n)
{
int i;
long long result;
/**********found**********/
result = ___1___;
/**********found**********/
for(i=2;i<=___2___;i++)
{
/**********found**********/
result = result * ___3___;
}
return result;
}
int main()
{
int n;
scanf("%d",&n);
printf("%lld\n",fun(n));
return 0;
}
1
n
i
第1空初始化乘积result为1;第2空循环变量从2到n;第3空累乘。输入5,输出120。