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
  • 相关阅读:
    Flume案例:目录文件到HDFS
    Flume案例:本地文件到HDFS
    12c多租户架构下部署GoldenGate12c
    ogg_sqlserver_oracle_winerver2008
    ogg异构oracle-mysql
    搜索引擎 反向索引,为什么称之为反向索引?
    ORACLE 11G 之DATAGUARD搭建逻辑standby
    Java并发锁控制API详解
    Java中的锁分类与使用
    Spring Cloud入门(含案例介绍及源码)
  • 原文地址:https://www.cnblogs.com/111qqz/p/4844687.html
Copyright © 2011-2022 走看看