#include <stdio.h>
#include <math.h>
void main() {
double x, t, s = 0;
int i = 0;
scanf("%lf", &x);
t = 1;
while (fabs(t) >= 1e-6) {
s += t;
i++;
t = -t * x * x / (2 * i) / (2 * i - 1);
}
printf("%.2lf", s);
}
cosx値を求めて、次の近似式評価cosxによれば、1E-6時まで累積絶対値未満を必要とします。
おすすめ
転載: blog.csdn.net/qq_38490457/article/details/104738300
おすすめ
ランキング