/*
zoj_1926 模拟
木有想到一道水题纠结那么久,见错误代码。。
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <limits.h>
using namespace std;
int main()
{
//freopen("a.txt","r",stdin);
int n,i,low,high;
string say;
bool cheat;
while( cin>>n && n )
{
cin.get();
cheat=false;
low=0; high=11;
while( getline(cin,say) && say!="right on" )
{
if( say=="too high" && high>n )
high=n;
else if( say=="too low" && low<n )
low=n;
cin>>n;
cin.get();
}
if( n<=low || n>=high )
cheat=true;
if( cheat ) cout<<"Stan is dishonest\n";
else cout<<"Stan may be honest\n";
}
return 0;
}
/*一个错误代码。。
其实归根到底是我想错了,我以为只要n不在那个范围那么stan就骗人了。。
其实不是。那个n是猜测者猜的而已,要判断stan有没有骗人是要看stan对猜测者猜n时说的话的。。
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <limits.h>
using namespace std;
int main()
{
//freopen("a.txt","r",stdin);
int n,i,low,high;
string say;
bool cheat;
while( cin>>n && n )
{
cin.get();
cheat=false;
low=-INT_MAX; high=INT_MAX;
while( getline(cin,say) && say!="right on" )
{
if( say=="too high" )
{
if( n<=low ) || n>=high ) //这里明显错了,可是我一直没看出来。。。
cheat=true; //如果n>=high并且stan说too high那么stan是没有骗他的。。
else if( high>n )
high=n;
}
else if( say=="too low" )
{
if( n<=low || n>=high ) //这边同理,也是错的
cheat=true;
else if( low<n )
low=n;
}
cin>>n;
cin.get();
}
if( n<=low || n>=high )
cheat=true;
if( cheat ) cout<<"Stan is dishonest\n";
else cout<<"Stan may be honest\n";
}
return 0;
}
*/
zoj 1926
最新推荐文章于 2013-09-12 14:31:00 发布