Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #define _USE_MATH_DEFINES
- #include "math.h"
- #include <windows.h>
- using namespace std;
- int fact(int n) {
- switch (n) {
- case 0: return 1;
- case 1: return 1;
- default: {
- int k = 1;
- for (int i = 1; i <= n; i++)
- k *= i;
- return k;
- }
- }
- }
- double receq(double x, double f, double fk, double e, double xi, int i) {
- double t = xi * pow(x, 4) * (4 * i - 2 - x) * fact(4 * i - 6) / ((4 * i - 6 - x) * fact(4 * i - 2));
- f += t;
- if (abs(f - fk)) {
- return f;
- }
- else {
- return receq(x, f, fk, e, t, i + 1);
- }
- }
- void main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- setlocale(LC_ALL, "rus");
- double e;
- cout << "Введите точность вычисления" << endl;
- cin >> e;
- double x;
- cout << "Введите x" << endl;
- cin >> x;
- double k, t;
- k = (sin(x) + cos(x) - exp(-x)) / 2.0;
- double r;
- r = receq(x, x*(2 - x) / 2.0, k, e, x*(2 - x) / 2.0, 2);
- cout.precision(15);
- cout << "k = " << k << endl;
- cout << "r = " << r << endl;
- cin >> r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement