zoukankan      html  css  js  c++  java
  • uva 489

    In ``Hangman Judge,'' you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well as the guesses. Rules are the same as the classic game of hangman, and are given as follows:

    1. The contestant tries to solve to puzzle by guessing one letter at a time.
    2. Every time a guess is correct, all the characters in the word that match the guess will be ``turned over.'' For example, if your guess is ``o'' and the word is ``book'', then both ``o''s in the solution will be counted as ``solved.''
    3. Every time a wrong guess is made, a stroke will be added to the drawing of a hangman, which needs 7 strokes to complete. Each unique wrong guess only counts against the contestant once.
         ______   
         |  |     
         |  O     
         | /|    
         |  |     
         | /     
       __|_       
       |   |______
       |_________|
    4. If the drawing of the hangman is completed before the contestant has successfully guessed all the characters of the word, the contestant loses.
    5. If the contestant has guessed all the characters of the word before the drawing is complete, the contestant wins the game.
    6. If the contestant does not guess enough letters to either win or lose, the contestant chickens out.

    Your task as the ``Hangman Judge'' is to determine, for each game, whether the contestant wins, loses, or fails to finish a game.

    Input

    Your program will be given a series of inputs regarding the status of a game. All input will be in lower case. The first line of each section will contain a number to indicate which round of the game is being played; the next line will be the solution to the puzzle; the last line is 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 is to indicate which round of the game the contestant is currently playing as well as the result of the game. There are three possible results:

    You win.
    You lose.
    You chickened out.

    Sample Input

    1
    cheese
    chese
    2
    cheese
    abcdefg
    3
    cheese
    abcdefgij
    -1

    Sample Output

    Round 1
    You win.
    Round 2
    You chickened out.
    Round 3
    You lose.


    水题还wa.真是药丸.药丸啊...
     1 /*************************************************************************
     2     > File Name: code/uva/489.cpp
     3     > Author: 111qqz
     4     > Email: rkz2013@126.com 
     5     > Created Time: 2015年09月23日 星期三 19时34分34秒
     6  ************************************************************************/
     7 
     8 #include<iostream>
     9 #include<iomanip>
    10 #include<cstdio>
    11 #include<algorithm>
    12 #include<cmath>
    13 #include<cstring>
    14 #include<string>
    15 #include<map>
    16 #include<set>
    17 #include<queue>
    18 #include<vector>
    19 #include<stack>
    20 #include<cctype>
    21 #define y1 hust111qqz
    22 #define yn hez111qqz
    23 #define j1 cute111qqz
    24 #define ms(a,x) memset(a,x,sizeof(a))
    25 #define lr dying111qqz
    26 using namespace std;
    27 #define For(i, n) for (int i=0;i<int(n);++i)  
    28 typedef long long LL;
    29 typedef double DB;
    30 const int inf = 0x3f3f3f3f;
    31 const int N=30;
    32 int a[N];
    33 int main()
    34 {
    35   #ifndef  ONLINE_JUDGE 
    36    freopen("in.txt","r",stdin);
    37   #endif
    38     int cas;
    39     while (scanf("%d",&cas)!=EOF)
    40     {
    41     if (cas==-1) break;
    42     ms(a,0);
    43     printf("Round %d
    ",cas);
    44     
    45     string st1,st2;
    46     cin>>st1>>st2;
    47     int len1 = st1.length();
    48     for ( int i = 0 ; i < len1 ; i++)
    49     {
    50         int tmp = st1[i]-'a';
    51         a[tmp]++;
    52     }
    53     int len2 = st2.length();
    54     int cnt = 0 ;
    55     int sum = 0 ;
    56     int state = 0;
    57     for ( int i = 0 ; i < len2 ; i++)
    58     {
    59         int tmp = st2[i]-'a';
    60         if (a[tmp]==0)
    61         {
    62         cnt++;
    63         }
    64         else
    65         {
    66         sum += a[tmp];
    67         a[tmp] =  0;
    68         }
    69         if (cnt>=7) break;
    70         if (sum==len1)
    71         {
    72         state = 1;
    73         break;
    74         }
    75     }
    76     if (state ==1)
    77     {
    78         puts("You win.");
    79         continue;
    80     }
    81 //    cout<<"cnt:"<<cnt<<endl;
    82     if (cnt<7)
    83     {
    84         puts("You chickened out.");
    85     }
    86     else
    87     {
    88         puts("You lose.");
    89     }
    90     }
    91    
    92  #ifndef ONLINE_JUDGE  
    93   fclose(stdin);
    94   #endif
    95     return 0;
    96 }
    View Code
  • 相关阅读:
    将aaaa替换成aaba 分类: python 小练习 2013-10-28 18:28 246人阅读 评论(0) 收藏
    使用生成器返回fibs列表 分类: python Module python基础学习 2013-10-28 18:19 283人阅读 评论(0) 收藏
    python中的生成器(generator) 分类: python Module python基础学习 2013-10-28 17:41 310人阅读 评论(0) 收藏
    遇到的问题总结 分类: 问题总结 2013-10-28 17:21 263人阅读 评论(0) 收藏
    win7 下安装ipython 分类: python基础学习 software 2013-10-19 12:23 1383人阅读 评论(0) 收藏
    获取函数中的参数 分类: 正则表达式 2013-10-16 15:14 221人阅读 评论(0) 收藏
    使用termcolor模块 分类: python Module 2013-10-12 14:06 459人阅读 评论(0) 收藏
    Mysql启动失败
    java-抽象类
    java三大特性--多态(1)
  • 原文地址:https://www.cnblogs.com/111qqz/p/4844687.html
Copyright © 2011-2022 走看看