current position:Home>What should I fill in the air room?

What should I fill in the air room?

2022-02-02 21:45:02 CSDN Q & A



Refer to the answer 1:
if(i % 2){s+= 1.0/(2*i - 1);}else{s-= 1.0/(2*i - 1);}

Refer to the answer 2:

Refer to the answer 3:

Modified it , But the result is entering 0.001 when , The return is 0.7849, I don't know , For your reference :

#include <stdio.h>#include <math.h>#include <stdlib.h>double fun(double x){        double s=0,i;    int n = (int)(1/x +1)/2;    for(i=1;i<=n;i++){        if(((int)i)%2==0){            s+=(double)1/(2*i-1)*-1;        }else{            s+=(double)1/(2*i-1);        }    }        return s;}int main(){// void NONO();    double x,sum;    printf("Enter x:\n");    scanf("%lf",&x);    sum=fun(x);    printf("sum=%.4lf\n",sum);// NONO();    return 0;}

Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended