int main()
{
int a = 0;
double sum = 0.0;
for (a = 1; a <= 100; a++)
{
sum += 1.0 / a;
}
printf("%lf\n", sum);
return 0;
}
int main()
{
int a = 0;
double sum = 0.0;
int b = 1;
for (a = 1; a <= 100; a++)
{
sum += b * 1.0 / a;
b = -b;
}
printf("%lf\n", sum);
return 0;
}
标签:分数,int,0.0,sum,加减,double,main
From: https://blog.51cto.com/u_16329505/8184384