题意再明白不过了……只有真的猜数对了才老实,其他一切情况都不老实。
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
int n,h=15,l=-1;
char a[10],c;
while(scanf("%d%c",&n,&c)&&n)
{
gets(a);
if(strcmp(a,"too high")==0)
{
if(h>=n) h=n;
}
else if(strcmp(a,"too low")==0)
{
if(l<=n) l=n;
}
else
{
if(n>l&&n<h) cout<<"Stan may be honest"<<endl;
else cout<<"Stan is dishonest"<<endl;
l=-1;
h=15;
}
}
return 0 ;
}