13,826
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<math.h>
int main()
{
double s=0.0,tmp=1.0;
int i=1,f=1;
for(i=1;fabs(tmp)>=1e-9;i+=2){
tmp=1.0*f/i;
s+=tmp;
f=-f;
}
printf("PI=%.10lf\n",4*s);
return 0;
}