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