489 Hangman Judge (UVA)

目录

AC source code:

Vocabulary:

 "turned over"is equal to elimination.

AC source code:

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
char s[105];
char b[105];
int main()
{
	int k;
	while(scanf("%d",&k)&&k!=-1)
        {
            int sum=0,f=0;
            memset(s,0,sizeof(s));
            memset(b,0,sizeof(b));
            scanf("%s %s",s,b);
            int len=strlen(s);
            for(int i=0;i<strlen(b);i++)
            {
                int p=0;
                for(int j=0;j<strlen(s);j++)
                {
                    if(b[i]==s[j])
                    {
                        p=1;
                        len--;
                        s[j]=' ';
                    }
                }
                if(p==0) sum++;
                if(sum>=7||len==0) break;
            }
            printf("Round %d\n",k);
            if(sum>=7) printf("You lose.\n");
            else if(len==0) printf("You win.\n");
            else printf("You chickened out.\n");
	}
	return 0;
}

Vocabulary:

 

猜你喜欢

转载自blog.csdn.net/qq_59414507/article/details/121546654