第1个回答 推荐于2018-04-22
#include<stdio.h>
int main(void)
{
int i = 1; double t = 0.0, s = 0.0;
while(i <= 100)
{
double index = 1.0 / (double)i;
if(i % 2 == 0) index = -index;
//printf("%f ", index);
s += index;
i++;
}
printf("%lf\n", s);
return 0;
}本回答被网友采纳