这个题,小模拟,AC的代码默写自紫书,注意输入输出
AC的代码
#include <bits/stdc++.h>
using namespace std;
const int N = 101;
int l,sum;
char s[N],s1[N];
bool win,lose;
void guess(char ch){
bool flag=1;
for(int i=0;i<strlen(s);i++) if(s[i]==ch){
l--;s[i]=' '; //将原串一样的字符清空
flag=false;// sum--;
}
if(flag) sum--;
if(!sum) lose=1;
if(!l) win=1;
}
int main(){
int rnd;
while(scanf("%d%s%s",&rnd,s,s1)==3&&rnd!=-1){
printf("Round %d\n",rnd);
win=lose=0;
l=strlen(s);
sum=7;
for(int i=0;i<strlen(s1);i++){
guess(s1[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;
}