#include<stdio.h>
int main()
{
int i = 1;
int flag = 1;
double sum = 0;
for (i = 1; i <= 100; i++)
{
sum += flag * (1.0 / i);
flag = -flag;
}
printf("总共的和为%lf", sum);
return 0;
}


程序:计算1/1-1/2+1/3......-1/100_c++