Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- char ch = ' ';
- int n=50,l=1,r=100;
- while (l!=r){
- std::cout << "Your number is larger, smaller or equal to " << n << "? " <<std::endl;
- std::cin >> ch;
- if(ch=='>') l=n;
- if(ch=='<') r=n;
- if(ch=='=') return 0;
- n=(l+r)/2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement