Ответы
Ответ дал:
0
#include <cstdio>
#include <cmath>
double
factorial(double n)
{
return n < 2 ? 1 : n * factorial(n - 1);
}
int
main(void)
{
int n = 0;
double x = 0;
scanf("%d %lf", &n, &x);
double amount_row = 0;
for (int i = 0; i < n; i++) {
double tmp = std::pow(x, 2 * i) / factorial(2 * i);
if (i & 1) {
tmp *= -1;
}
amount_row += tmp;
}
printf("%9.7lfn%9.7lfn", amount_row, std::cos(x));
return 0;
}
#include <cmath>
double
factorial(double n)
{
return n < 2 ? 1 : n * factorial(n - 1);
}
int
main(void)
{
int n = 0;
double x = 0;
scanf("%d %lf", &n, &x);
double amount_row = 0;
for (int i = 0; i < n; i++) {
double tmp = std::pow(x, 2 * i) / factorial(2 * i);
if (i & 1) {
tmp *= -1;
}
amount_row += tmp;
}
printf("%9.7lfn%9.7lfn", amount_row, std::cos(x));
return 0;
}
Вас заинтересует
2 года назад
2 года назад
2 года назад
9 лет назад
9 лет назад