网课任务,实在是不会了,谁能看看啊

img

img

img

只学了几天的c语言,想了半天才想出来的,结果不行,谁可以帮忙改改啊


#include <stdio.h>
#include<math.h>
 
double fact(int n)
{
    if (n == 0)
        return 1;
    return fact(n - 1)*n;//求1-(2*n-1)的阶层
}
double fact_2(int n)
{
    long sum = 1;
    while (n > 1)
    {
        sum *= n;
        n--;
    }
    return sum;
} //第二种计算阶层的方法
int main()
{
    int n = 1, j = 1;//n是项数,j是正负
    double x, sinx = 0, order = 1;//x是项,sinx是结果,order是项值
    scanf_s("%lf", &x);
    while (order >= 1e-3) //精度
    {
        order = pow(x, 2 * n - 1) / fact(2 * n - 1);
        sinx += j * order;
        j = -j;
        n++;
    }
    printf("sinx=%lf", sinx );
    getchar();
    getchar();
    return 0;
}

粘贴代码