#include <stdio.h>
int main()
{
int a = 1;
double b = 0.0;
int c = 1;
for (a = 1; a <= 100; a++)
{
b += 1.0/ a*c; //1.0的原因是为了产生小数,否则1/比一大的数都为0
c = -c; //*c的目的是使其实现所求的式子1-1/2+1/3-1/4等
}
printf("之和为:%lf", b);
return 0;
}