489 Hangman Judge (UVA)

目录

AC source code:

Vocabulary:

489 Hangman Judge (UVA)

489 Hangman Judge (UVA)

 "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:

489 Hangman Judge (UVA)

489 Hangman Judge (UVA)

 489 Hangman Judge (UVA)

上一篇:剑指 Offer 26. 树的子结构(java & python)


下一篇:《数据结构与面向对象程序设计》实验二实验报告20202309葛鹏宇