标签:
题目大意:Sample Input1 cheese chese 2 cheese abcdefg 3 cheese abcdefgij -1 Sample OutputRound 1 You win. Round 2 You chickened out. Round 3 You lose. |
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main () {
int times;
while (scanf("%d", ×) == 1 && times != -1) {
char s[100];
int a[26] = {0}, b[26] = {0};
scanf("%s", s);
int len = strlen(s);
for (int i = 0; i != len; ++i)
a[s[i] - ‘a‘] = 1;
scanf("%s", s);
len = strlen(s);
int cnt = 0;
bool flag = false;
for (int i = 0; i != len; ++i) {
if (!a[s[i] - ‘a‘]) {
if (++cnt >= 7) {
printf("Round %d\nYou lose.\n", times);
flag = true;
break;
}
}
else {
a[s[i] - ‘a‘] = -1;
bool ok = true;
for (int j = 0; j != 26; ++j) {
if (a[j] == 1) {
ok = false;
break;
}
}
if (ok) {
printf("Round %d\nYou win.\n", times);
flag = true;
break;
}
}
}
if (!flag)
printf("Round %d\nYou chickened out.\n", times);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/liangyongrui/p/4564696.html