zoj 1926 Guessing Game
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int a[20],i,j,n,f;
char s[100];
memset(a,0,sizeof(a));
f=1;
while(~scanf("%d",&n))
{
if(n==0) break;
gets(s);
if(strcmp(s,"too high")==0)
{
for(i=n;i<=10;i++)
{
if(a[i]==-1) f=0;
a[i]=1;
}
}
else if(strcmp(s,"too low")==0)
{
for(i=1;i<=n;i++)
{
if(a[i]==1) f=0;
a[i]=-1;
}
}
else if(strcmp(s,"right on")==0)
{
if(a[n]!=0) f=0;
if(f)
//if(a[n]==0)
printf("Stan may be honest\n");
else printf("Stan is dishonest\n");
memset(a,0,sizeof(a));
f=1;
}
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/