SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. const double eps = 1e-12;
  5. double func(double x) {
  6.     return log(x);
  7. }
  8.  
  9. int main()
  10. {
  11.     cout << "Vvedite tochost" << endl;
  12.     double eps;
  13.     cin >> eps;
  14.     double a,b;
  15.     cout << endl << "Vvedite diapazon" << endl;
  16.     cin >> a >> b;
  17.     double c = (a+b)/2;
  18.     double y1 = func(a);
  19.     double y2 = func(c);
  20.     int fl = 0;
  21.     while (abs(c-a)>eps || y1*y2>0) {
  22.         if (y1*y2 <= 0) {
  23.           c = (a+c)/2;
  24.           y1 = func(a);
  25.           y2 = func(c);
  26.         }
  27.         else {
  28.             a = c;
  29.             c = b;
  30.             y1 = func(a);
  31.             y2 = func(c);
  32.         }
  33.         if (c-a < eps/2 && y1*y2>0) {
  34.             fl = 1;
  35.             break;
  36.         }
  37.     }
  38.     if (fl==1) cout << "Kornei net";
  39.     else cout << a<< "     " << c;
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top