Hangman JudgeTime
limit:3000MS
Memory Limit:0KB
64bit IO Format:%lld &%llu SubmitStatusPracticeUVA 489Appoint Description:DaNao (2011-04-19)System Crawler (2016-03-19)
Description
In "Hangman Judge," You're to-write a program that judges a series of the Hangman games. For each game, the answer to the puzzle are given as well as the guesses. Rules is the same as the classic game of Hangman, and is given as follows:
- The contestant tries to solve to puzzle by guessing one letter at a time.
- Every time a guess is correct and all of the characters in the word that match the guess would be "turned over." For example, if your guess is "o" and the word is "book", then both "O ' s in the solution would be counted as" solved .‘‘
- Every time a wrong guess is made, a stroke would be added to the drawing of a hangman, which needs 7 strokes to complete. Each unique wrong guess is only counts against the contestant once.
______ | | | O |/|\ | | |/\ __|_ | | ______ |_________|
- If the drawing of the hangman is completed before the contestant have successfully guessed all the characters of the word, The contestant loses.
- If The contestant have guessed all the characters of the word before the drawing are complete, the contestant wins the game.
- If The contestant does not guess enough letters to either win or lose, the contestant chickens out.
Your task as the ' Hangman Judge ' is-determine, for each game, whether-contestant wins, loses, or fails to finish A game.
Input
Your program would be given a series of inputs regarding the status of a game. All input would be in the lower case. The first line of all sections would contain a number to indicate which round of the game is being played; The next line is being the solution to the puzzle; The last line was a sequence of the guesses made by the contestant. A round number of 1 would indicate the end of all games (and input).
Output
The output of your program was to indicate which round of the game the contestant are currently playing as well as the Resul T of the game. There is three possible results:
You win. You lose. You are chickened out.
Sample Input
1cheesechese2cheeseabcdefg3cheeseabcdefgij-1
Sample Output
Round 1You win. Round 2You chickened out. Round 3You lose.
#include <bits/stdc++.h>using namespacestd;intMain () {intN; while(cin>>N) {if(n==-1) Break; Charpuz[1050]; Chargus[1050]; intdid[ -]; scanf ("%s", Puz);//GetChar ();scanf"%s", Gus);//GetChar (); //cout<<puz<<endl; //cout<<gus<<endl; intflag[1050]; intstok=0; intright=0; memset (Flag,0,sizeof(flag)); Memset (did,0,sizeof(did)); //cout<<flag[2]<<endl; intFindc=0; for(intI=0; I<strlen (Gus); i++) { if(stok>6) Break; FINDC=0; for(intj=0; J<strlen (Puz); J + +) { if(gus[i]==puz[j]&&flag[j]==0) {Flag[j]=1; Right++; FINDC=1; } } if(!FINDC) {if(!did[gus[i]-'a']) stok++; did[gus[i]-'a']=1;} if(stok<7&&right==strlen (Puz)) {cout<<"Round"<<n<<endl<<"You win."<<endl; Break;} } if(stok<7&&right<strlen (Puz)) cout<<"Round"<<n<<endl<<"You are chickened out."<<Endl; if(stok>6) cout<<"Round"<<n<<endl<<"You lose."<<Endl; //Cout<<right<<endl<<strlen (puz) <<endl; } return 0;}
Consider a variety of situations: The first n entries have already been matched, the remaining 7+m are not matched, so we have to end early.
UVA 489 Hangman Judge