UVA 489 Hangman Judge

#include <cstdio>
#include <cstring>

int main() {
	int n;
	while (scanf("%d", &n), n+1) {
		getchar();
		printf("Round %d\n", n);
		char s1[200], s2[200], s3[200], s4[200];
		int arr[30] = {0}, brr[30] = {0};
		gets(s1);
		gets(s2);
		int len_1 = strlen(s1);
		int len_2 = strlen(s2);
		int count_1 = 0, count_2 = 0, count_3 = 0, count_4 = 0;
		for (int i = 0; i < len_1; i++)
			if (s1[i] && !arr[s1[i] - 'a']) {
				s3[count_1++] = s1[i];
				arr[s1[i] - 'a']++;
			}
		for (int i = 0; i < len_2; i++)
			if (s2[i] && !brr[s2[i] - 'a']) {
				s4[count_2++] = s2[i];
				brr[s2[i] - 'a']++;
			}
		for (int i = 0; i < count_2; i++) {
			for (int j = 0; j < count_1; j++) {
				if (s4[i] == s3[j]) {
					count_3++;
					break;
				}
				if (j == count_1 - 1)
					count_4++;
			}
			if (count_4 == 7) {
				printf("You lose.\n");
				break;
			}
			if (count_3 == count_1) {
				printf("You win.\n");
				break;
			}
			if (i == count_2 - 1)
				printf("You chickened out.\n");
		}
	}
	return 0;
}

你可能感兴趣的:(UVA 489 Hangman Judge)