99问答网
所有问题
c语言 用π/4≈1 - 1/3 + 1/5 - 1/7 + ……公式求π的近似值。
如题所述
举报该问题
推荐答案 2015-01-13
#include<stdio.h>
int main()
{
double item=1;
double sum=0;
int flag=1, step=1;
while(item/step>=1e-6 || item/step<=-1e-6)
{
sum+=flag*item/step;
flag*=-1;
step+=2;
}
printf("pi=%lf\n",sum*4);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://99.wendadaohang.com/zd/vWzjzXBeOzOBttOOevO.html
相似回答
大家正在搜
相关问题
在C语言中用Π/4≈1-1/3+1/5-1/+..........
C语言小白求助:用π/4≈1-1/3+1/5-1/7+。。。...
编程题:用π/4≈1-1/3+1/5-1/7+……公式求π的...
C语言 下面的流程图是用π/4≈1-1/3+1/5-1/7+...
c语言π/4≈1-1/3+1/5-1/7+...公式求π的近...
C语言编程。利用公式:π/4=1-1/3+1/5-1/7+…...
请教C语言问题,大神速来 高分 π/4≈1-1/3+1/5-...
编写程序用下面公式求π的近似值 π/4 ≈ 1- 1/3+1...