同一个问题第三次发帖,
又写了一个又错了
#include <stdio.h>
int main(){
//用while循环求 1-1/2+1/3-1/4+1/5-1/6+........-1/100 的和
float n=1.0 ,sum=0;
while(n <= 100&&n % 2 = 1);
sum=sum+1/n;
else{"sum = sum-1/n";
n++};
printf("sum=%lf\n",sum);
return 0;
}
#include <stdio.h> int main(int argc,char *argv[]) { int n =0; double m ,sum; while(n < 100){ n++; m = n*(1+n); sum += 1/m; n++; } printf("%lf",sum); return 0; }