编程计算如下表达式的值,直到最后一项的绝对值小于0.00001为止。 1+1⼀3+1⼀5+1⼀7+1⼀9…

2025-04-14 14:42:34
推荐回答(1个)
回答1:

//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
    int i;
    double s,tmp;
    for(s=0.0,tmp=i=1;(tmp=1.0/i)>=0.00001;s+=tmp,i+=2);
    printf("The result is %f\n",s);
    return 0;
}