Here it is.
#include<iostream>
using namespace std;
int main()
{
int l,h,m,mm,n,i;
string res="NEW";
cin>>l>>h;
m=(l+h)/2;
mm=m-1;
while(1)
{
if(m==mm)
res[0]=='L'?m++:m--;
cout<<m<<endl;
mm=m;
cin>>res;
if(res[0]=='W')
break;
if(res[0]=='L')
l=m;
else
h=m;
m=(l+h)/2;
fflush(stdout);
}
return 0;
}
Could you just tell me the approach to solve this one.