下列给定程序中,函数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));}

下列给定程序中,函数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));

}


相关考题:

下列给定程序中,函数fun()的功能是:求出以下分数序列的前n项之和。2/1,3/2,5/3,8/5,13/8,21/13,……和值通过函数值返回main()函数。例如,若输入n=5,则应输出8.391667。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio.h>/*************found**************/fun (int n){ int a=2,b=l,c, k;double s=0.0;for(k=l;k<=n;k++){s=s+l.0*a/b;/*************found**************/c=a; a+=b; b+=c;}return (s);}main (){ int n=5;clrscr ();printf("\nThe value of function is:%1f\n", fun (n));}

给定程序MODI1.C中函数fun的功能是:用下面的公式:π/4=1-1/3+1/5-1/7+.....求x的近似值,直到最后一项的绝对值小于指定的数(参数num)为止:例如,程序运行后,输入0.0001,则程序输出3.1414。请改正程序中的错误,使它能输出正确的结果。_______注意:不要改动smain函数,不得增行或删行,也不得更改程序的结构!include 〈 math.h 〉include 〈 stdio.h 〉float fun (float num){ int s ;float;n,t,pi ;t=1;pi=0;n=1;s=1;/**********found**********/while(t 〉=num){pi = pi + t ;n = n +2 ;s=-s ;/**********found**********/t = s % n ;}pi=pi*4 ;return pi ;}main(){ float n1,n2;printf(Enter a float number:);scanf(%f, n1);n2=fun(n1);printf(%6.4f\n,n2);}

下列给定的程序中,函数fun()的功能是:求出以下分数序列的前n项和。2/1,3/2,5/3,8/5,13/8,21/13,…其值通过函数值返回main()函数。例如,若输入n=5,则应输出8.391667。[注意] 部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。[试题源程序]include<stdio.h>include<conio.h>double fun(int n){int a=2, b=1, c, k;double (1) ;for(k=1; k<=n; k++){s=s+1.0 *a/b;c=a; a+= (2) ; b=c;}return(d);}main(){int n=5;printf("\nThe value of function is: %1f\n", (3) );}

请编写一个函数fun(),它的功能是:根据以下公式求π的值(要求满足精度0.005,即某项小于0.005时停止迭代)。π/2=1+1/3+1*2/(3*5)+1*2*3/(3*5*7)+1*2*3*4/(3*5*7*9)+…+1*2*3*…*n/(3*5*7*…*(2n+1))程序运行后,如果输入精度0.0005,则程序输出3.14…。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<conio.h>include<math.h>double fun(double eps){}main(){double x;printf("Input eps: ");scanf("%1f", x);printf("\neps=%1f,PI=%1f\n",x,fun(x));}

下列程序定义了N×N的二维数组,并在主函数中赋值。请编写函数fun(),函数的功能是:求出数组周边元素的平均值并作为函数值返回给主函数中的s。例如:若a数组中的值为a= 0 1 2 7 91 9 7 4 52 3 8 3 14 5 6 8 25 9 1 4 1则返回土程序后s的值应为3.375。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的仟何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <stdio.h>include<conio.h>include<stdlib.h>define N 5double fun (int w[] [N]){}main(){int a[N] [N]={0,1,2,7,9,1,9,7,4,5,2,3,8,3,1,4,5,6,8,2,5,9,1,4,1};int i, j;double s;clrscr();printf("*****The array*****\n ");for (i=0; i<N; i++){ for (j=0;j<N;i++){printf("%4d ",a[i] [j]);}printf("\n ");}s=fun(a);printf("*****THE RESULT*****\n ");printf("The sum is : %lf\n ",s);}

下列程序定义了NXN的二维数组,并在主函数中赋值。请编写函数fun(),函数的功能是求出数组周边元素的平方和并作为函数值返回给主函数中的S。例如:若a数组中的值为a=0 1 2 7 91 11 21 5 52 21 6 11 19 7 9 10 25 4 1 4 1则返回主程序后s的值应为310。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<stdio.h>include<conio.h>include<stdlib.h>define N 5int fun (int w[][N]){}main(){int a[N)[N]={0,1,2,7,9,1,1l,2l,5,5,2, 21,6,11,1,9,7,9,10,2,5,4,1,4,1};int i,j;int S;clrscr( );printf("*****The array***+*\n");for (i=0; i<N; i++){for(j=0;j<N;i++){printf(“%4d”,a[i][j]);}printf("\n");}s=fun(a);printf(“*****THE RESULT*****\n”);printf("The sum is:%d\n",s);}

下列给定程序中,函数fun()的功能是:用下面的公式求π的近似值,直到最后一项的绝对值小于指定的数(参数num)为止。π/4≈1-1/3+1/5-1/7+…例如,程序运行后,输入0.0001,则程序输出3.1414。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <math.h>include <stdio.h>float fun(float num){ int s;float n,t, pi;t=1 ;pi=0; n=1; s=1;/**************found***************/while (t>=num){pi=pi+ t;n=n+2;s=-s;/**************found**************/t=s% n;}pi=pi*4;return pi;}main (){ float n1, n2;clrscr ();printf ("Enter a float number: ");scanf ("%f", n1);n2=fun (n1);print f (" %6.4 f\n ", n2);}

下列给定程序中,函数fun()的功能是:根据以下公式求n的值,并作为函数值返回。例如,给指定精度的变量eps输入 0.0005时,应当输出Pi=3.140578。n/2=1+1/3+1/3*2/5+1/3*2/5*3/7+1/3*2/5*3/7*4/9……请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio.h>include <math.h>double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",x);printf("\nPi=%1f\n ",fun(x));}

【程序说明】 程序功能是用两种循环步长值来求1+2+3+…+50的值。【程序一】S=0FOR (5)(6)ENDFOR? SRETURN【程序二】S=0FOR (7)S=S+NENDFOR(8)RETURN(5)A.N=50 TO 1B.N=1 TO 50 STEP-1C.N=1 TO 50D.S=1 TO 50