Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cctype>
- using namespace std;
- int main() {
- cout << "PICK AN INTEGER BETWEEN 1 AND 100 INCLUSIVE, PEON" << endl;
- int low = 1, high = 100;
- while (true) {
- int guess = (low + high) / 2;
- cout << "is ur number " << guess << "? [Yes/Higher/Lower]" << endl;
- string response;
- getline(cin, response);
- if (response.empty()) continue; // wut
- if (tolower(response[0]) == 'y') { cout << "YUP I WINZ"; break; }
- if (tolower(response[0]) == 'h') { low = guess + 1; }
- if (tolower(response[0]) == 'l') { high = guess - 1; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement