源码
#include <cstdio>
#include <cstring>
#define maxn 1000005
char s[maxn],s1[maxn];
int v[30];
int len_s,len_s1;
int error ;
bool guess(char c)
{
int r = strlen(s);
int flag = 0;
if(v[c - 'a'])
return false;
for(int i = 0;i < r;++i)
{
if(s[i] == c)
{
// printf("v[%d] = %c\n",i,s[i]);
flag = 1;
len_s--;
v[s[i] - 'a'] = 1;
}
}
if(flag)
return true;
else
return false;
}
int main()
{
int k;
while(~scanf("%d",&k))
{
if(k == -1)
break;
error = 0;
scanf("%s%s",s,s1);
for(int i = 0;i < 26;++i)
v[i] = 0;
len_s = strlen(s);
len_s1 = strlen(s1);
int j;
for(j = 0;j < len_s1;++j)
{
if(error == 7)
{
break;
}
int f = guess(s1[j]);
if(len_s == 0)
break;
if(!f)
++error;
}
//printf("len_s == %d error = %d\n",len_s,error);
// for(int i = 0;i < 26;++i)
// printf("%d ",v[i]);
if(!len_s && error < 7)
{
printf("Round %d\nYou win.\n",k);
}
else if(j == len_s1 && error < 7)
printf("Round %d\nYou chickened out.\n",k);
else
printf("Round %d\nYou lose.\n",k);
}
}