UVA 489 - 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-1would 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.

 

 

 

 

#define RUN
#ifdef RUN

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <cctype> 
#include <algorithm>
#include <utility>
#include <math.h>

using namespace std;

#define MAXN 105

int n;
char solution[MAXN];
char guess[MAXN];

int flag[MAXN];

void play(){

	memset(flag, 0, sizeof(flag));
	
	int i, j;
	int wrong = 0;

	for(i=0; i<strlen(guess); i++){

		bool iswrong = true;

		// Check if it is a same character as previous examined one
		char* pch = strchr(guess, guess[i]);
		if(pch!=NULL && pch-guess==i){
			for(j=0; j<strlen(solution); j++){

				if(flag[j]==0 && solution[j]==guess[i]){
					flag[j] = 1;
					iswrong = false;
				}
			}
			if(iswrong){
				wrong++;
			}
			if(wrong >= 7){
				break;
			}
		}
	}

	printf("Round %d\n", n);

	// Examine
	int k = 0;
	for(k=0; k<strlen(solution); k++){
		if(flag[k] == 0){
			if(wrong < 7){
				printf("You chickened out.\n");
				return;
			}
			else{
				printf("You lose.\n");
				return;
			}
		}
	}

	if(k == strlen(solution)){
		printf("You win.\n");
	}

}


int main(){

#ifndef ONLINE_JUDGE
	freopen("489.in", "r", stdin);
	freopen("489.out", "w", stdout); 
#endif

	while(scanf("%d", &n)==1 && (n!=-1)){

		memset(solution, '\0', sizeof(solution));
		memset(guess, '\0', sizeof(guess));
		scanf("%s%s", solution, guess);
		//printf("%s\n", ans);
		//printf("%s\n", guess);

		play();
	}


}


#endif



 

小米机型解锁bl 绕过社区等级5才可以解锁的限制的教程 小米机型目前限制了解锁bl的机制。从以前单一的绑定解锁到目前绑定账号必须小米社区5级的条件限制。切必须要答题分数够才可以申请解锁。限制的根本原因也在为消费者提供更好的服务。避免刷机小白无基础常识解锁bl后第三方固件或者软件造成的故障。另外一方面也在于市场格机脚本等类似原因导致的售后返修率 阅读详情

相关推荐

1.STM32H743VGT6最小系统板

此款MCU具备较大算力进行频谱运算,为复杂数据运算提供更高效的保障。该MCU具备REV-V和REV-Y两个型号,后者为新版本。

Audiation88的博客 3794

UVa_489 - Hangman Judge

 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 ...

weixin_34162228的博客 347

自制电吉他效果器 DIY PCB(二)电路图分析

自制DIY电吉他效果器 PCB(二)电路图分析 要自制一款效果器,看懂电路图是必须的,即使你已经有了完整的设计电路图,在电路的绘制已久焊接的时候电路知识都会用到。 在效果器电路中,比较简单的是过载失真类效果器的电路。混响延迟等与声相有关的由于电路比较复杂本人也没有尝试过。其他的例如EQ、哇音等等效果器复杂程度依设计各不相同,在能做出过载失真类效果器后,可以自行尝试。 我这里主要为大家介绍失真效果器...

qq_41342525的博客 2万+

出厂非澎湃OS手机解BL锁

脚本作者:酷安@mlgmxyysd脚本项目链接:https://github.com/MlgmXyysd/Xiaomi-HyperOS-BootLoader-Bypass/参考 B站作者:蓝空穹 https://www.bilibili.com/read/cv33210124/其他参考:云墨清风、水墨青竹、Magisk中文网。

crownyouyou的博客 1万+

自举电容的工作原理-3句话总结

1、一道面试题 照例,先抛出来一道面试题:“Buck电路的SW引脚通常会放置一颗小电容,这颗电容有什么用?”。这个问题问得比较细,非常考验被面试者的硬件基本功。 2、似懂非懂的答案 有小伙伴可能不太清楚这颗电容的作用,回答不上来。也有小伙伴脱口而出:自举电容,用来做升压的。但后面好像说不出来具体逻辑。 没具体了解过,答不上来,也没啥可惜的。但是了解过一点,但又似懂非懂的这种,给出的答案只是轻轻点水或者千篇一律,那无疑是错过了一个加分项。 3、异步Buck的自举环路组成 既然是针对Buck电路讲自举电容,前面

ltqdxl的博客 3万+

Paypal开发者中心获取“ClientId”和“ClientSecret”参数

正式环境设置 1、登录到 paypal开发者中心 网址:https://developer.paypal.com/developer/ 点击右上角登录按钮登录 2、左侧栏 - 我的应用程序和凭证 - 点击“创建新应用” 新注册的paypal账号,需要进行邮箱验证,验证通过后,需要等待一段时间(或重新登录),才会出现相关设置项位置 验证邮箱通过后,点击创建新应用 3、按提示填写,保存创建应用 4、点击刚创建的应用进入应用详情页 5、应用详情页获得网站开发人员所需要的“ClientId”和“Client

龚清林的博客 1万+

小米手机突破小米社区5级等级限制解锁BL教程。小米手机解锁。

小米社区对于解锁BootLoader(BL)的等级限制一直是一个热议话题。特别是对于小米澎湃OS用户来说,官方要求社区等级达到5级才能解锁BL,这对于许多用户来说是一个不小的挑战。不过,现在有了一种方法可以绕过这个限制,让我们一起来看看如何操作。

m0_74205854的博客 1万+

UART中断接收的实战陷阱:HAL库常见误区与性能调优指南

本文深入解析STM32 HAL库UART中断接收机制,揭示常见实战陷阱如数据溢出、中断优先级配置不当等,并提供性能调优方案。重点介绍如何使用空闲中断处理不定长数据、DMA与中断混合模式优化,以及工业级错误恢复与流量控制策略,帮助开发者构建稳定可靠的串口通信系统。

pea55的博客 747

Hangman Judge UVA - 489

题目链接:Hangman Judge UVA - 489 简单题。。。 #include #include #include #include #include #include #include #include #include #include #define ll long long using namespace std; int main(){ int t,vis[2

howell 195

从零学懂车载 TSN(二):802.1AS、Qbv、Qbu 是如何让 Ethernet “按时发送”的?

假设有两台设备: ECU A 认为: 但 Switch B 认为: 如果我们规定: 问题就来了。ECU:Switch:整个调度立即失效。因此 TSN 要做时间调度,第一件事就是:这就是:IEEE 802.1AS 定义时间敏感网络里的:工程中通常会看到:gPTP也就是:generalized Precision Time Protocol可以先简单理解成: 核心表达:所有 TSN 节点使用共同时间。后面抓包时你会经常遇到: 刚入门时不用急着研究每个 bit。先搞清楚它们解决什么问题。两个设备连接: A 需要知

struggle_22_58的博客 49

GJB软件需求规格说明-编制指南

《软件需求规格说明》是软件开发过程必不可少的文档,并且需要评审,也是后续鉴定试验的依据,因此,非常有必要认真对待此文档。 文档对于很多开发技术人员来说是一件非常头疼的事,虽然标准有要求,但是光看标准还是难以下笔。 本文将详细讲解如何按照GJB 438C的要求编写《软件需求规格说明》。 注:文中有背景颜色内容为标准内容,加粗部分为范例。斜体部分为解释。 全文1.3万字

Abel的博客 6352

UVA - 489 ​​​​​​​Hangman Judge

Hangman Judge  UVA - 489  题目传送门 PS.此题Udebug有毒,即使100组样例全过,但还是WA,心塞。 这是我自己的代码,悲催的WA了 #include &lt;cstdio&gt; #include &lt;iostream&gt; #include &lt;algorithm&gt; #include &lt;cmath&gt; #include &l...

C++的星空 204

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

【UVA】 489 --- Hangman Judge

【UVA】 489 --- 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...

来日浅谈的博客 485

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

【基础练习】【模拟】Uva489 - Hangman Judge题解

ruka(刘汝佳《算法竞赛入门经典》第二版)第四章的例题,原题目使用函数写的,我读了代码后自己写了一遍,没有用函数,调了十几分钟,写这篇题解总结一下教训。 题目大意是判断输入的字符串是否猜中 猜中一个字母就猜中了所有相同字母 重复猜一个字母算错 一共有七次猜错机会 如果机会内猜对就赢了(win) 用光机会就输了(lose) 没用光但也没猜对就是放弃了 (chickend out) 代码放上:

西家家 1092

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

uva 489 Hangman Judge

489 - Hangman Judge

AC__GO的博客 415

uva489 Hangman Judge

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

SeeBro专栏 3020

UVa 489 Hangman Judge

Hangman JudgeIn “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 cl

平行空间 408

【UVA 489 --- Hangman Judge】

【UVA 489 --- Hangman Judge】 题目来源:点击进入【UVA 489 — Hangman Judge】 Description In ``Hangman Judge,’’ you are to write a program that judges a series of Hangman games. For each game, the answer to the puzz...

来日浅谈的博客 561

[UVa 489] 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 ...

weixin_37992828的博客 208

Uva489_Hangman Judge心得感悟

其实碰到看题目有就一点思路的题,我就知道题目其实不是很难,也不会转很多弯子,所以信心满满的写了个个大概思路去做了就。 第一阶段,写出的代码能差不多符合例样的数值,本想着对着udebug的数值就可以,结果一对发现太多答案不对了,这下我懵逼了。 ** **问题:**利用split函数时,"."作为特殊字符,需要利用//来转义,学到了学到了。 ** 第二阶段,试着看了一下输入输出格式(其实第一阶段的时候...

qq_43736081的博客 286

UVA489Hangman 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: The contestant trie

qq_34596217的博客 239

UVA489 刽子手的游戏 Hangman Judge

题目描述 PDF 输入格式 输出格式 题意翻译 刽子手游戏是一款猜单词游戏,计算机想一个单词让你猜,你每次可以猜一字母 如果单词里有那个字母,所有该字母会显示出来。(例如“book”,如果猜字母“o”,则两个o都会显示出来) 如果没有那个字母,则计算机会在一幅“刽子手”画上填一 笔。这幅画一共需要7 笔就能完成,因此你最多只能错6 次。 注意,猜一个已经猜过的字母也算错。在本题中,模拟这个过...

YUEXILIULI的博客 1948
上一篇: android之intent的Flag详解
下一篇: UVA 489 - Hangman Judge
chiiis
博客等级 码龄14年 422粉丝 429原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值