Hangman Judge 

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.

一个字符串的游戏  有一个你不知道的字符串  你開始有7条命  然后你每次猜一个字母  若你猜的字母在原字符串中  原字符串就去掉全部那个字母  否则你失去一条命   假设你在命耗完之前原字符串中全部的字母都被猜出  则你赢   假设你在命耗完了原字符串中还有字母没被猜出  则你输    假设你在命没耗完原字符串中也还有字母没被猜出  视为你放弃

给你还有一个字符串作为你猜的顺序  推断你能否赢:

//UVa489 Hangman
#include<cstdio>
#include<cstring>
using namespace std;
const int N = 1000;
char a[N], b[N];
int cas, la, lb, i, j;
int main()
{
while (scanf ("%d", &cas), cas + 1)
{
scanf ("%s %s", a, b);
la = strlen (a);
lb = strlen (b);
int ca[26] = {0}, left = 7;
for (i = 0; i < la; ++i)
++ca[a[i] - 'a'];
for (i = 0; i < lb; ++i)
if (ca[b[i] - 'a'] != 0)
{
ca[b[i] - 'a'] = 0;
for (j = 0; j < 26; ++j)
if (ca[j] != 0) break;
if (j == 26)
{
printf ("Round %d\nYou win.\n", cas);
break;
}
}
else if (--left == 0)
{
printf ("Round %d\nYou lose.\n", cas);
break;
}
if (i == lb) printf ("Round %d\nYou chickened out.\n", cas);
}
return 0;
}

UVa 489 Hangman Judge(字符串)的更多相关文章

  1. uva 489 Hangman Judge(水题)

    题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&am ...

  2. uva 489.Hangman Judge 解题报告

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  3. UVA 489 Hangman Judge (字符匹配)

    题意:给一个字符串A,只含小写字符数个.再给一个字符串B,含小写字符数个.规则如下: 1.字符串B从左至右逐个字符遍历,对于每个字符,如果该字符在A中存在,将A中所有该字符删掉,若不存在,则错误次数+ ...

  4. uva 489 Hangman Judge

    大意:电脑想个单词,玩家来猜.玩家输入一个个字母,若答案里有这个字母,则显示该单词中所有该字母.最终目标是显示答案所有字母.猜错7次,死: 注意特殊条件:1.玩家不断重复错误的字母,只算一次猜错.2. ...

  5. uvaoj 489 - Hangman Judge(逻辑+写代码能力)

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  6. Hangman Judge UVA - 489

    In ``Hangman Judge,'' you are to write a program that judges a series of Hangman games. For each gam ...

  7. UVa 489 HangmanJudge --- 水题

    UVa 489 题目大意:计算机给定一个单词让你猜,你猜一个字母,若单词中存在你猜测的字母,则会显示出来,否则算出错, 你最多只能出错7次(第6次错还能继续猜,第7次错就算你失败),另注意猜一个已经猜 ...

  8. UVA.12169 Disgruntled Judge ( 拓展欧几里得 )

    UVA.12169 Disgruntled Judge ( 拓展欧几里得 ) 题意分析 给出T个数字,x1,x3--x2T-1.并且我们知道这x1,x2,x3,x4--x2T之间满足xi = (a * ...

  9. UVA 12169 Disgruntled Judge 扩展欧几里得

    /** 题目:UVA 12169 Disgruntled Judge 链接:https://vjudge.net/problem/UVA-12169 题意:原题 思路: a,b范围都在10000以内. ...

随机推荐

  1. Microsoft SQL Server学习(三)

    1.表:表示一个实体(客观存在的事物或抽象时间),可实现对实体的数据描述和数据操作. 2.表结构:二位平面(行.列) 3.数据类型: 类型名称 类型 整形 bit(只存储0.1) samllint i ...

  2. java设计模式之单例模式总结

    面试手写单例模式(通用版)

  3. 北大ACM(POJ1016-Numbers That Count)

    Question:http://poj.org/problem?id=1016 问题点:水题. Memory: 232K Time: 125MS Language: C++ Result: Accep ...

  4. 微服务网关从零搭建——(三)Ocelot网关 + identity4

    增加验证服务 1.创建名为AuthService 的core 空项目 2.修改startup文件 using System; using System.Collections.Generic; usi ...

  5. Win实用好用软件清单推荐

    1. 我的Win实用软件清单 排名不分先后且长期更新 有更好用的或者需要帮助的可以留言----最后一次更新于 2019.06.25 1. Dism++ 1.1. 功能: ​ 系统精简.垃圾清理.系统升 ...

  6. thupc & cts & apio & thusc 游记 (北京17日游记)

    thupc & cts & apio & thusc 游记 (北京17日游记) Day 0 和隔壁校两人py了一下,六个人组了两队,(左哼哼)与(右哼哼),我和Camoufla ...

  7. 如何允许WebGL从本地载入资源

    随着mono-design不断推广,用户越来越多,陆续有电话来询问“为什么3D展现的时候,是一团黑?”,针对这个问题,专门写个帖子说明原因并给出解决方案,并且在mono-design编辑器中加了判断功 ...

  8. Vue.js 模板语法

    本章节将详细介绍 Vue.js 模板语法,如果对 HTML +Css +JavaScript 有一定的了解,学习起来将信手拈来. Vue.js 使用了基于 HTML 的模版语法,允许开发者声明式地将 ...

  9. 题解 洛谷P1501/BZOJ2631【[国家集训队]Tree II】

    Link-Cut-Tree 的懒标记下传正确食用方法. 我们来逐步分析每一个操作. 1:+ u v c:将u到v的路径上的点的权值都加上自然数c; 解决方法: 很显然,我们可以 split(u,v) ...

  10. 51nod 1118 机器人走方格【dp】

    M * N的方格,一个机器人从左上走到右下,只能向右或向下走.有多少种不同的走法?由于方法数量可能很大,只需要输出Mod 10^9 + 7的结果. 收起 输入 第1行,2个数M,N,中间用空格隔开.( ...