题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-07-27 06:17:55

[填空题]函数pi的功能是根据以下公式近似求得的:
pi*pi/6=1+1/(2*2)+1/(3.3)+...+1/(n*n)
请在下面的函数中天空,完成求pi的功能。
#include<math.h>
double pi(long n)
double s=0.0,long i;
for(i=1;i<<=n;i++)s=s+ 【11】 ;
return(sqrt(6*s));

更多"函数pi的功能是根据以下公式近似求得的: pi*pi/6=1+1/"的相关试题:

[填空题]函数pi的功能是根据以下公式近似求得的:
pi*pi/6=1+1/(2*2)+1/(3*3)+…+1/(n*n)
请在下面的函数中填空,完成求pi的功能。
#include<math.h>
double pi(long n)
doubles=0.0,long i;
for(i=1;i<=n;i++)s=s+ 【11】 ;
return(sqrt(6*s));

[填空题]函数pi的功能是根据以下近似公式求π值:
[*]
请在下面的函数中填空,完成求π的功能。
#include <math.h>
double pi(long n)
double s = 0.0;
long i;
for(i = 1;i <= n; i++) s = s + ;
return (sqrt(6*s));

[填空题]函数pi的功能是根据以下近似公式求π值:
(π*π)/6=1+1/(2*2)+1/(3*3)+...+1(n*n)
现在请你在下面的函数中填空,完成求π的功能。
#include "math.h"
double s=0.0; long i;
for(i=1;i<=n;i++)s=s+ 【10】 ;
return (sqrt(6*s));

[填空题]函数void fun(float *sn,int n)的功能是:根据以下公式计算s,计算结果通过形参指针 sn传回;n通过形参传入,n的值大于或等于0。请填空。
[*]
void fun(float *sn,int n)
float s=0.0,w,f=-1.0;
int i;
for(i=0;i<=n;i++)
f= * f;
w=f/(2*i+1);
s+=w;

=s;

[填空题]函数viod fun(float * sn,int n)的功能是:根据以下公式计算S,计算结果通过形参指针sn传回;n通过形参传入,n的值大于等于0。请填空。   s=1-1/3+1/5-1/7+…1/(2n+1)   void fun(float * sn,int n)   { floats=0.0,w,f=-1.0;   int i=0;   for(i=0;i<=n;i+ +)   { f= 【19】 * f;   w=f/(2i+1);   s+ +=w;   }    【20】 =s;   }
[填空题]函数void fun(float*sn,int n)的功能是:根据以下公式计算S,计算结果通过形参指针sn传回;n通过形参传入,n的值大于等于0。请补全程序。 S=1-1/3+1/5-1/7+…+1/(2n+1) void fun(float*sn,int n) { float s=0.0,w,f=-1.0; int i=0; for(i=0;i<=n;i++) { f= 【14】 *f; w=f/(2*i+1); s+=w; } 【15】 =s; }
[简答题]编写函数proc( ),函数的功能是:根据以下公式计算s,计算结果作为函数值返回,m通过形参传入。
S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+m)
例如,若n的值为11时,函数的值为1.833333。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
float proc(int m)


void main( )

int m;
float s;
system ("CLS");
printf("/nPlease enter M: ");
scanf("%d", &m);
s=proc(m);
printf("The result is: %f/n", s);

[简答题]编写函数fun( ),函数的功能是:根据以下公式计算s,计算结果作为函数值返回;n通过形参传入。 S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+n) 例如:若n的值为11时,函数的值为1.833333。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include <conio.h> #include <stdio.h> #include <string.h> float fun(int n) { } main( ) { int n; float s; clrscr( ); printf("/nPlease enter N: "); scanf("%d",&n); s=fun(n); printf("The result is:%f/n " , s); }
[填空题]下列给定程序中,函数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)); }

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码