这个程序怎么没结果输出?
#include "math.h"main()
{
int a,b;
float s;
a=-1,b=1,s=1.0;
while(fabs(s)>1e-6)
{b=b+2;
a=-a;
s=s-a/b;
}
printf("%10.6f\n",s*4);
}
怎么没求出3.1415926的值呢?
各位高手帮帮我这个初学者。。
2007-05-14 17:10
2007-05-14 17:50
2007-05-14 18:07
2007-05-14 18:39
#include \"stdio.h\"
#include \"math.h\"
main()
{
float s,a,b;
a=-1,b=1,s=1.0;
while(fabs(a/b)>1e-6)
{
b=b+2;
a=-a;
s=s-a/b;
}
printf(\"%10.6f\n\",s*4);
}
2007-05-14 21:11