Guest User

NUMGUESS

a guest
Apr 18th, 2015
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int a, b;
  9.     cin >> a >> b;
  10.  
  11.     int middle;
  12.     string ans;
  13.  
  14.     while (a <= b) {
  15.         middle = ((a + b) / 2);
  16.  
  17.         cout << middle << endl;
  18.         cout.flush();
  19.  
  20.         cin >> ans;
  21.         if (ans == "WIN")
  22.             break;
  23.         else if (ans == "LOW")
  24.             a = middle + 1;
  25.         else
  26.             b = middle - 1;
  27.     }
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment