5-3
![](http://images0.cnblogs.com/blog/571409/201310/08165613-72106d68ce2f46949b1b6885cc7c702f.png)
#include<stdio.h> #include<math.h> int main(void) { double e,pi; double funpi(double e); printf("Enter e:"); scanf("%lf",&e); pi=funpi(e); printf("pi=%f\n",pi); return 0; } double funpi(double e) { int denominator,flag; double item,sum; flag=1; denominator=1; item=1.0; sum=0; while(fabs(item)>=e){ item=flag*1.0/denominator; sum=sum+item; flag=-flag; denominator=denominator+2; } return sum*4; }