Seeking sinx values: to approximate sinx according to the following equation, an absolute value of the accumulated required until the time is less than 1e-6.

Here Insert Picture Description

#include <stdio.h>
#include <math.h>

void main() {
    double x, t, s = 0;
    int i = 0;
    scanf("%lf", &x);
    t = x;
    while (fabs(t) >= 1e-6) {
        s += t;
        i++;
        t = -t * x * x / (2 * i) / (2 * i + 1);
    }
    printf("%.2lf", s);
}
Published 139 original articles · won praise 4 · Views 930,000 +

Guess you like

Origin blog.csdn.net/qq_38490457/article/details/104738006