#include<cstdio>
#include<cstring>
#define maxn 100
int left,chance;
char s[maxn],s2[maxn];
int lose,win;
void guess(char ch)
{
int bad=1;
for(int i=0;i<strlen(s);i++)
if(ch==s[i]){left--;s[i]=' ';bad=0;}
if(bad)--chance;
if(!chance) lose = 1;
if(!left) win = 1;
}
int main()
{
int game;
while(scanf("%d%s%s",&game,s,s2)==3&&game!=-1)
{
printf("Round %d\n",game);
win=lose=0;
left=strlen(s);
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");
}
}
第 1 測資點(100%): WA (line:16)
答案不正確
您的答案為: You lose. 正確答案為: You chickened out.
#include
#include
#define maxn 100
int left,chance;
char s[maxn],s2[maxn];
int lose,win;
void guess(char ch)
{
int bad=1;
for(int i=0;i if(ch==s[i]){left--;s[i]=' ';bad=0;}
if(bad)--chance;
if(!chance) lose = 1;
if(!left) win = 1;
}
int main()
{
int game;
while(scanf("%d%s%s",&game,s,s2)==3&&game!=-1)
{
printf("Round %d\n",game);
win=lose=0;
left=strlen(s);
chance = 7;
for(int i=0;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");
}
}
第 1 測資點(100%): WA (line:16)
答案不正確
您的答案為: You lose. 正確答案為: You chickened out.
如果不想思考或是不想看題目,可以來信,我可以回答你的疏漏之處。