按照题意来说是多个猜错的相同字符只算一次,猜已经猜过的算错;
但是下面的代码ac了,其逻辑是猜已猜对的不算错,多个猜错的算多次错误。
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <ctype.h>
char info[4][20] = { "You win.",
"You chickened out.",
"You lose.",
"You lose." };
int main()
{
int n;
int flag[26];
char s[105], t[105];
while (scanf("%d", &n) && n != -1)
{
scanf("%s %s", s, t);
memset(flag, 0, sizeof(flag));
int ch_count = 0;
int wrong_count = 0;
for (int i = 0; i < strlen(s); i++)
{
int index = s[i] - 'a';
if (!(flag[index]++))
ch_count++;
}
for (int i = 0; i < strlen(t); i++)
{
int index = t[i] - 'a';
if (flag[index] == 0)
{
wrong_count++;
if (wrong_count >= 7)
break;
}
else
{
if (flag[index] > 0)
{
flag[index] *= -1;
ch_count--;
}
if (!ch_count)
break;
}
}
printf("Round %d\n%s\n", n, info[(wrong_count >= 7) * 2 + (ch_count != 0)]);
}
return 0;
}