1106: 【实验6.1.2 模块化程序设计】
金币值:2
定数:3
时间限制:1.000 s
内存限制:128 M
正确:19
提交:21
正确率:90.48% 命题人:
题目描述
请修改程序,保证运行正确。
#include <stdio.h>
double fact(int n)
{
if(n<0) return -1;
else if(n=0 || n=1) /*ERROR*/
return 1;
else
return n*fact(n-1);
}
int main(void)
{
int n;
int result; /*ERROR*/
scanf("%d",&n);
result=fact(n);
if(result==-1)
printf("Please input a number: ");
else
printf("The factorial of the number is %lf\n",result);
return 0;
}
输入样例 复制
9
输出样例 复制
The factorial of the number is 362880.000000