Advertisement
Evgeniy175

Untitled

Nov 17th, 2014
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     setlocale(LC_CTYPE, "Russian");
  6.     double x, a = 8, b = 12, S, h, S1, S2, L1, L2;
  7.     int i, n=200;
  8.     h = (b - a) / (2 * n);
  9.     x = a + 2 * h;
  10.     S1 = 0;
  11.     S2 = 0;
  12.     for (i = 1; i < n; i++)
  13.     {
  14.         S2 += 2 - pow(x, 2) + x;
  15.         x += h;
  16.         S1 += 2 - pow(x, 2) + x;
  17.         x += h;
  18.     }
  19.     L1 = 2 - pow(a, 2) + a;
  20.     L2 = 2 - pow(b, 2) + b;
  21.     S = h*(L1 + 4 * (L1 + h) + 4 * S1 + 2 * S2 + L2) / 3;
  22.     cout << "S = " << S << "\n";
  23.     system("pause");
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement