Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- #include <clocale>
- using namespace std;
- void func(double Xn, double Xk, double dX, double e) {
- for (double x = Xn; x <= Xk; x += dX) {
- double F = 0, Fn;
- double p = 1;
- int n = 0;
- do {
- Fn = F;
- if (n == 0) p = 1;
- else p = p * n;
- F += ((pow(-1, n) * pow(x, n)) / p);
- n++;
- } while (fabs(F - Fn) > e);
- cout << x << " " << setprecision(4) << F << " " << setprecision(4) << (n - 1) << " " << setprecision(4)
- << exp(-x) << endl;
- }
- }
- int main() {
- setlocale(LC_ALL, "Russian");
- double Xn, Xk, dX, e;
- cout << "Введите Xn, Xk, dX и точность e:" << endl;
- cin >> Xn >> Xk >> dX >> e;
- func(Xn, Xk, dX, e);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement