#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int left, chance;
int win, lost;
char ans[101], in[101];
void guess(char c);
int main() {
int T = 0, i = 0;
while (scanf("%d%s%s", &T, ans, in) == 3 && T != -1) {
win = lost = 0;
chance = 7;
left = strlen(ans);
for (i = 0; i < strlen(in); i++) {
guess(in[i]);
if (win || lost) break;
}
printf("Round %d\n", T);
if (win)
printf("You win.\n");
else if (lost)
printf("You lose.\n");
else
printf("You chickened out.\n");
}
return 0;
}
void guess(char c) {
int i = 0, found = 0;
for (i = 0; i < strlen(ans); i++) {
if (c == ans[i]) {
ans[i] = ' ';
found = 1;
left--;
}
}
if (!found) chance--;
if (!left) {
win = 1;
return;
} else if (!chance) {
lost = 1;
return;
}
return;
}
489 - Hangman Judge
最新推荐文章于 2024-02-12 22:58:53 发布