Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- const double eps = 1e-12;
- double func(double x) {
- return log(x);
- }
- int main()
- {
- cout << "Vvedite tochost" << endl;
- double eps;
- cin >> eps;
- double a,b;
- cout << endl << "Vvedite diapazon" << endl;
- cin >> a >> b;
- double c = (a+b)/2;
- double y1 = func(a);
- double y2 = func(c);
- int fl = 0;
- while (abs(c-a)>eps || y1*y2>0) {
- if (y1*y2 <= 0) {
- c = (a+c)/2;
- y1 = func(a);
- y2 = func(c);
- }
- else {
- a = c;
- c = b;
- y1 = func(a);
- y2 = func(c);
- }
- if (c-a < eps/2 && y1*y2>0) {
- fl = 1;
- break;
- }
- }
- if (fl==1) cout << "Kornei net";
- else cout << a<< " " << c;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement