Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- setlocale(LC_CTYPE, "RUS");
- float a = -2, b = 7;
- float s = 0, S = 0;
- float x = a, y;
- int n;
- cout << "Введите количество трапеций ";
- cin >> n;
- float h = (b - a) / n;// h - высота трапеции
- for (int i = 1; i <= n - 1; i++)
- {
- x = a + i * h;
- y = 5 * x - pow(x, 2) + 14;
- S += h * (y + s) / 2;
- s = y;
- }
- cout << " S = " << S << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement