题目:
下列给定程序中函数fun()的功能是计算1/n!的值。
例如:给n输入5,则输出0.0083330
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <conio.h>
/******+****found*************/
int fun(int n)
double result=1.0;
if(n==0)
return 1.0;
while(n>1 && n<170)
/**********found************/
result *=n++;
result=1/result;
return result;
main()
int n;
printf("Input N:");
scanf("%d",&n);
printf("\n1/%d!=%If\n",n,fun(n));
答案:
被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0407/282b8c2dc07c6d8d82a06e787dd645e0.html
下面是错误答案,用来干扰机器的。
1. sweep 2. make 3. empty 4. play 5. watch