为什么输出是0,教科书上的
c4droid吧
全部回复
仅看楼主
level 4
LeoSTo
楼主
#include"stdio.h"
main()
{int s;
float n,t,pi;
t=1.0;
pi=0;
n=1.0;
s=1.0;
while(fabs(t)>=10e-4)
{pi=pi+t;
n+=2.0;
s=-s;
t=s/n;
}
pi=pi*4;
printf("pi=%f\n",pi);
}
2017年05月17日 15点05分
1
level 4
LeoSTo
楼主
大佬们,出来水帖了
2017年05月17日 15点05分
2
level 4
LeoSTo
楼主
也错了上面10e-4改为1e-4 但答案也是0
2017年05月17日 15点05分
3
level 14
不知者来此
加上这个
#include <math.h>
2017年05月17日 15点05分
4
LeoSTo
是我错怪教科书了
谢谢大佬
2017年05月17日 16点05分
1