Advertisement
High_Light

naxogdenie cornja metodom delenija

Nov 17th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main()
  8. {
  9.     //cin>>n;
  10.     double a=0;
  11.     double b=3;
  12.     double x=2;
  13.  
  14.     while ((b-a)>0.00001){
  15.             double c=(a+b)/2;
  16.             if ((c*c)>x){
  17.             b=c;
  18.         }
  19.             else if ((c*c)<x){
  20.             a=c;
  21.             cout << c<< endl;
  22.         }
  23.  
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement