task16
unknown
c_cpp
2 years ago
502 B
8
Indexable
#include <iostream>
#include <locale.h>
//16. Вычислить функцию y=e^x c заданной точностью.
double myExp(double x, double eps) {
double cn = x;
double s = 1 + cn;
for (int i = 2; cn > eps; i++) {
cn = cn*x/i;
s += cn;
}
return s;
}
int main() {
setlocale(LC_ALL, "");
double x, eps;
printf("Введите x и epsilon: ");
scanf_s("%lf %lf", &x, &eps);
double res = myExp(x, eps);
printf("e^x с точностью epsilon = %lf\n", res);
return 0;
}Editor is loading...
Leave a Comment