#include<stdio.h>
#include<math.h>
int main()
{
double i,n,sum,eps,term;
scanf("%lf",&eps);
sum=0;
i=1;
n=1;
do{
sum=sum+term;
n=-n;
i=i+3;
term=n/i;
}while(fabs(term)>eps);
printf("%f",sum);
}
本题要求编写程序,计算序列部分和 1 - 1/4 + 1/7 - 1/10 + ... 直到最后一项的绝对值不大于给定精度eps
qq_无言_fqJN09
望远
相关分类