zoj 1926 Guessing Game

来源:互联网 发布:上海华腾软件 编辑:程序博客网 时间:2024/04/28 00:37
#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;}
0 0