这种题就不应该错了!!啊啊啊啊啊啊啊啊啊啊我还耗了那么久/(ㄒoㄒ)/~~
sum=1,…,index=1, …mu+=2,…zi=-zi,…index=1.0*zi/mu…sum+=index;
#include
#include
using namespace std;
int main()
{
double eps,sum=1;
cin>>eps;
double index=1,mu=1,zi=1;
while(abs(index)>=eps){
mu=mu+2;
zi=-zi;
index=1.0*zi/mu;
sum=sum+index;
}
printf("Pi = %.4lf",4*sum);
}