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

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std; const int maxn = ; int l, chance;
char s[maxn], s2[maxn];
int win, lose; void guess(char ch)
{
int bad = ;
for (int i = ; i < strlen(s); i++) {
if (s[i] == ch) {
l--;
s[i] = '#';
bad = ;
}
}
if (bad) --chance;
if (!chance) lose = ;
if (!l) win = ;
} int main()
{
int rnd;
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
while (scanf("%d%s%s", &rnd, s, s2) == && rnd != -) {
printf("Round %d\n", rnd);
win = lose = ;
l = strlen(s);
chance = ;
for (int i = ; i < strlen(s2); i++) {
guess(s2[i]);
if (win || lose) break;
} if (win) printf("You win.\n");
else if (lose) printf("You lose.\n");
else printf("You chickened out.\n");
}
return ;
}

uva 489.Hangman Judge 解题报告的更多相关文章

  1. UVa 489 Hangman Judge(字符串)

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

  2. uva 489 Hangman Judge(水题)

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

  3. uva 489 Hangman Judge

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

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

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

  5. 【LeetCode】997. Find the Town Judge 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 度 日期 题目地址:https://leetcode ...

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

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

  7. UVa -1584 Circular Sequence 解题报告 - C语言

    1.题目大意 输入长度为n$(2\le n\le 100)$的环状DNA串,找出该DNA串字典序最小的最小表示. 2.思路 这题特别简单,一一对比不同位置开始的字符串的字典序,更新result. 3. ...

  8. UVa 455 - Periodic Strings解题报告

    UVa OJ 455 Periodic Strings A character string is said to have period k if it can be formed by conca ...

  9. hrbustoj 1494(原题UVA 315 Network) 解题报告 tarjan求割点

    主要思路:使用tarjan选取一个根节点建立一个棵搜索树,判断一个点是割点的充分必要条件是,对于一个节点u如果他的孩子节点v的low值大于等于u的出生日期dfn值,进行下一步判断,如果u是我们选的根节 ...

随机推荐

  1. MYSQL 连接数据库命令收藏

    一.MySQL 连接本地数据库,用户名为“root”,密码“123”(注意:“-p”和“123” 之间不能有空格) C:\>mysql -h localhost -u root -p123 二. ...

  2. Zepto.js touch模块深入分析

    目的:记录 Zepto.js touch模块 源码阅读 源码: // Zepto.js // (c) 2010-2015 Thomas Fuchs // Zepto.js may be freely ...

  3. WCF绑定类型选择

    WCF绑定类型选择   发布日期:2010年12月10日星期五 作者:EricHu   在开发WCF程序时,如何选择一个适合的绑定对于消息传输的可靠性,传输模式是否跨进程.主机.网络,传输模式的支持. ...

  4. iOS:使用MVC模式帮ViewController瘦身

    如何给UIViewController瘦身 随着程序逻辑复杂度的提高,你是否也发现了App中一些ViewController的代码行数急剧增多,达到了2,3千行,甚至更多.这时如果想再添加一点功能或者 ...

  5. noip2012 疫情控制

    [问题描述] H国有n个城市,这n个城市用n-1条双向道路相互连通构成一棵树,1号城市是首都,也是树中的根节点. H国的首都爆发了一种危害性极高的传染病.当局为了控制疫情,不让疫情扩散到边境城市(叶子 ...

  6. xcode7 The operation couldn't be completed.

    问题描述:当运行Xcode6时,编译代码成功,但是登陆模拟器失败,显示错误:The Operation couldn't be completed.(LaunchServicesError error ...

  7. svn更改默认服务启动目录

    配置文件位于 /etc/sysconfig/svnserve 修改为自己的目录

  8. JS获取地址栏参数

    获取地址栏参数(其中name为你所需要的参数值) function GetQueryString(name) { var reg = new RegExp("(^|&)" ...

  9. Swift初学有一点难理解的东西,整理了一下,想明白了。

      func makeIncrementer() -> (Int -> Int) {      func addOne(number: Int) -> Int {           ...

  10. 51Nod 1378 夹克老爷的愤怒

    Description 一棵树,可以进行染色,被染色的点可以控制与它距离不超过 \(k\) 的所有点,问控制整棵树最少需要染几个点. Sol 贪心. 记录一下最深的未染色点和最浅的染色点,判断一下能否 ...