Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "RUS");
- int n;
- double a, b, h, S, Y, r
- cout << "Введите a" << endl;
- cin >> a;
- cout << "Введите b" << endl;
- cin >> b;
- cout << "Введите h" << endl;
- cin >> h;
- cout << "Введите n" << endl;
- cin >> n;
- for (double x = a; x <= b; x += h) {
- r = 1; S= 1;
- int k = 1;
- while (k<=n){
- r *= x / (2*k);
- S += r * (k*k + 1);
- k++;
- }
- Y = (x*x / 4 + x / 2 + 1)*exp(x / 2);
- cout << setw(10)<<"s="<<S<<setw(10)<<"y="<<Y<<setw(10)<<"s-y="<<abs(S-Y) <<endl;}
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment