求1-1/2+1/3-1/4~~~~~~~+1/99-1/100。这个题是谭浩强书上的,他那些定义的数把我转晕了也没搞懂。新手求解
#include<stdio.h>int main()
{
int sign=1;
double deno = 2.0,sum = 1.0,term;
while(deno <= 100)
{
sign = -sign;
term = sign/deno;
sum = sum+term;
deno = deno+1;
}
printf("%f\n",sum);
return 0;
}
就这个把我都转晕了。没清晰的理解清楚