填空题

下列给定程序中,函数fun()的功能是;求S的值。设 S=(22/1*30))*(42/(3*5))*(62/(5*7))*…*(2k)2/((2k-1)*(2k+1))
例如,当k为10时,函数的值应为1.533852。
请改正程序中的错误,使它能得出正确的结果。
注童;不要改动main 函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio. h>
#include <stdio. h>
#include <math.h >
/**************found***************/
fun (int k)
iht n; float s, w, p, q;
n=1;
s=1.0;
while (n<=k)
w=2. 0*n;
p=w-1.0;
q=w+1.0;
s=s*w*w/p/q;
n++;

/***************found**************/
return s
main()
clrscr ();
printf ("%f\n ", fun (10));

【参考答案】

(1)错误:fun(int k) 正确:double fun(int k)
(2)错误:return s ......

(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)