#include<stdio.h>
#include<math.h>int main(){int sign=1;//数值的符号int count=0;//累计计算循环的次数double pi=0.0;double n=1;//分母double term=1.0;//当前项的数while(fabs(term)>=1e-6){//fabs(trem)=|term|pi=pi+term;n=n+2;sign=-sign;term=sign/n;count++;}pi=pi*4;printf("pi的近似是:");printf("pi=%10.8f\n",pi);printf("count=%d\n",count);return 0;
}