Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2016
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     char ch = ' ';
  6.     int n=50,l=1,r=100;
  7.     while (l!=r){
  8.         std::cout << "Your number is larger, smaller or equal to " << n << "? " <<std::endl;
  9.         std::cin >> ch;
  10.         if(ch=='>') l=n;
  11.         if(ch=='<') r=n;
  12.         if(ch=='=') return 0;
  13.         n=(l+r)/2;
  14.     }
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement