64,649
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <cstdio>
using namespace std;
#define maxn 100
int left,chance;
char s1[maxn],s2[maxn];
int win,lose;
void guess(char ch)
{
int flag=1;
for(int i=0;i<strlen(s1);i++)
if(s1[i]=ch)
{left--;s1[i]=' ';flag=0;}
if(flag) --chance;
if(!chance) lose=1;
if(!left) win=1;
}
int main()
{
int rnd;
while(scanf("%d%s%s",&rnd,s1,s2)!=EOF&&rnd!=-1){
printf("Round %d\n",rnd);
win=lose=0;
left=strlen(s1);
chance=7;
for(int i=0;i<strlen(s2);i++){
guess(s2[i]);
if(win||lose) break;
}
if(win) printf("You win.\n");
else if(lose) printf("You lose.\n");
else printf("You chickened out.\n");
}
return 0;
}