Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- double func(double x)
- {
- return (-x * x + 6 * x + 5);
- }
- double e = 0.01;
- double c;
- double perebor(double a, double b, int n)
- {
- double x, xmax;
- double y = func(a);
- for (int i = 0; i <= n; i++) {
- x = a + i * (b - a) / (n + 1);
- cout << "x=" << x << endl;
- cout << "f(" << x <<")=" << func(x)<<endl;
- if (func(x) > y) {
- y = func(x);
- xmax = x;
- }
- }
- cout << "Point of maximum is = " << xmax << endl;
- cout << "Extr is = " << y << endl;
- return 0;
- }
- int main()
- {
- double a, b;
- int n;
- a = 0;
- b = 5;
- cout << "a = " << a << endl;
- cout << "b = " << b << endl;
- cout << "Enter n:";
- cin >> n;
- perebor(a, b,n);
- cout << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement