#include<stdio.h>
int main()
{
int i, n, flag;
double sum, item;
scanf("%d", &n);
sum=0;
flag=1;
for(i=1; i<=n; i++){
item = flag*1.0*i/(2*i-1);
flag = -flag;
sum = sum+item;
}
printf("%.3f", sum);
return 0;
}
标签:int,double,sum,flag,交错,序列,习题,main
来源: https://www.cnblogs.com/ytmsnzy/p/16587877.html