AlexandrTalchuk

3.2.11

Dec 29th, 2019
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <math.h>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     setlocale(LC_ALL, "RUS");
  10.  int n;
  11.  double a, b, h, S, Y, r
  12.  cout << "Введите a" << endl;
  13.  cin >> a;
  14.  cout << "Введите b" << endl;
  15.  cin >> b;
  16.  cout << "Введите h" << endl;
  17.  cin >> h;
  18.  cout << "Введите n" << endl;
  19.  cin >> n;
  20.         for (double x = a; x <= b; x += h) {
  21.             r = 1; S= 1;
  22.             int k = 1;
  23.         while (k<=n){
  24.             r *= x / (2*k);
  25.             S += r * (k*k + 1);
  26.             k++;
  27.         }
  28.         Y = (x*x / 4 + x / 2 + 1)*exp(x / 2);
  29.         cout << setw(10)<<"s="<<S<<setw(10)<<"y="<<Y<<setw(10)<<"s-y="<<abs(S-Y) <<endl;}
  30.     system("pause");
  31.     return 0;
  32.  
  33. }
RAW Paste Data