Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // y = 3x^2 - 4x + 2
- // y = 20 - x
- #include <iostream>
- using namespace std;
- float f1(float x)
- {
- return 20 - x;
- }
- float f2(float x)
- {
- return 3 * x * x - 4 * x + 2;
- }
- int main()
- {
- setlocale(LC_ALL, "russian");
- cout << "y = 3x^2 - 4x + 2\ny = 20 - x\n";
- float a, b, n, h, s1 = 0, s2 = 0;
- cout << "Введите пределы интегрирования от a до b:\na: ";
- cin >> a;
- cout << "b: ";
- cin >> b;
- cout << "Введите количество интервалов разбиения: ";
- cin >> n;
- h = (b - a) / n;
- for (int i = 0; i <= n - 1; i++)
- {
- s1 += f1(a);
- s2 += f2(a);
- a += h;
- }
- cout << "Площадь: " << (s1 - s2) * h << endl;
- system("Pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement