int main()//计算1-1/2+1/3-1/4+......1/99+1/100的值
{
int i = 0;
double sum = 0.0;
int j = 1;
for (i = 1; i <= 100; i++)
{
sum += j * 1.0/ i;
j = -j;
}
printf("%f", sum);
return 0;
}
输出的结果为:
标签:int,double,sum,99,+......,100 From: https://blog.51cto.com/u_16170479/6974253