#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
const int MAX_VALUE = 100;
const int MIN_VALUE = 0;
int guess;
int high = MAX_VALUE;
int low = MIN_VALUE;
char choice;
cout<<"Think about a number between "<<MIN_VALUE<<" and "<<MAX_VALUE<<". \n\n";
guess = ( high-low ) / 2;
while(guess>low){
cout<<"Is your number less than or equal"<<guess<<"? \nEnter y or n. \n\n";
cin>>choice;
if(choice=='j' || choice=='J') {
high = guess;
if(high-low==1) guess=low;
else guess -= ( high - low ) / 2;
}
else if(choice=='n' || choice=='N') {
low = guess;
guess += (high - low ) /2;
}
else cout<<"Wrong answer."<<endl;
}
cout<<"Your number is: "<<high<<".\n";
return 0;
}
return 0;
}