题目内容:
下列给定程序中函数proc()的功能是计算1/n!的值。 例如,给n输入3,则输出0.166667。
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
#include<conio.h>
//****found****
int proc(int n)
{
double t=1.0;
if(n==0)
return 1.0;
while(n>1&&n<170)
//****found****
t*=n++:
t=1/t:
return t;
}
void main()
{
int n;
printf("Input N:");
scanf("%d",&n); printf("\hi/%d!=%lf\n",n,proc(n));
}
参考答案:
答案解析: