歼灭弱题3
我最早在 长毛猴子 李咏主持的幸运52中看到的猜数游戏
ZOJ1926
#include <iostream>
#include <string>
using namespace std;
int main()
{
int start,end;
bool ans=false;
int current;
string act;
start=0;
end=100;
while(cin >> current)
{
if(current==0)
break;
cin >> act;
cin >> act;
if(act=="low")
{
if(start<current)
start=current;
if(start>=end)
ans=true;
}
else if(act=="high")
{
if(end>current)
end=current;
if(start>=end)
ans=true;
}
else if(act=="on")
{
if(!(current>start&¤t<end))
ans=true;
if(ans==true)
cout << "Stan is dishonest" << endl;
else
cout << "Stan may be honest" << endl;
ans=false;start=0;end=100;
}
}
return 0;
}
ZOJ1926
#include <iostream>
#include <string>
using namespace std;
int main()
{
int start,end;
bool ans=false;
int current;
string act;
start=0;
end=100;
while(cin >> current)
{
if(current==0)
break;
cin >> act;
cin >> act;
if(act=="low")
{
if(start<current)
start=current;
if(start>=end)
ans=true;
}
else if(act=="high")
{
if(end>current)
end=current;
if(start>=end)
ans=true;
}
else if(act=="on")
{
if(!(current>start&¤t<end))
ans=true;
if(ans==true)
cout << "Stan is dishonest" << endl;
else
cout << "Stan may be honest" << endl;
ans=false;start=0;end=100;
}
}
return 0;
}
浙公网安备 33010602011771号