为什么只有13分,还差两分?
为什么只有13分,还差两分?
不懂
你while中的项数多加了一项,修改如下:
#include <stdio.h>
#include <math.h>
int main()
{
double t=1,pi=0,eps,z=1;
int m=1;
scanf("%lf",&eps);
while(eps<=fabs(t))
{
pi += t;
z = -z;
m+=2;
t = z/m;
}
printf("Pi = %.4lf",4*pi);
return 0;
}