新手虚心求教!
pai/4=1-1/3+1/5-1/7+...(直到最后一项绝对值小于10-5为止)#inelude<stdio.h>
#include<_______>
main()
{
double s=o,t=1;
int i=1,f=1;
while(fabs(t)>=1e-5)
{
s=______;
f=_______;
i=_______;
t=1.0*f/i;
}
s=______;
printf("圆周率为:%f\n",s);
} 可以用long double 你这是在找人帮你做作业吗?
#include<stdio.h>
#include<math.h>
main()
{
double s=0,t=1;
int i=1,f=1;
while(fabs(t)>=1e-5)
{
s=s+t;
f=-1*f;
i=i+2;
t=1.0*f/i;
}
s=s*4;
printf("圆周率为:%f\n",s);
} #include<stdio.h>
#include<math.h>
void main()
{
double s=0,t=1;
int i=1,f=1;
while(fabs(t)>=1e-5)
{
s=s+t;
f=-1*f;
i=i+2;
t=1.0*f/i;
}
s=s*4;
printf("圆周率为:%f\n",s);
}
求最佳{:10_254:}
页:
[1]