刽子手游戏(UVa489)
题目具体描述见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=430
C++11代码如下:
#include<iostream>
#include<string.h>
using namespace std;
char ans[], test[]; int main() {
int rnd;
while ((cin>>rnd>>ans>>test)&&rnd!=-) {
cout << "Round " << rnd << endl;
int chance = ;
int left_ch = strlen(ans);
for (int i = ; i < strlen(test); i++) {
bool bad = true;
for (int j = ; j < strlen(ans); j++) {
if (ans[j] == test[i]) {
ans[j] = ' ';
left_ch--;
bad=false;
}
}
if (bad) --chance;
if (!(left_ch && chance)) break;
}
if (!left_ch) cout << "You win."<<endl;
else if (!chance) cout << "You lose."<<endl;
else cout << "You chickened out."<<endl;
}
return ;
}
刽子手游戏(UVa489)的更多相关文章
- 刽子手游戏(Hangman Judge, UVa 489)
刽子手游戏其实是一款猜单词游戏,游戏规则是这样的:计算机想一个单词让你猜,你每次可以猜一个字母.如果单词里有那个字母,所有该字母会显示出来:如果没有那个字母,则计算机会在一幅“刽子手”画上填一笔.这幅 ...
- 4_2 刽子手游戏(UVa489)<自顶向下逐步求精法>
Hangman Judge是一个猜英文单字的小游戏(在电子字典中常会看到),游戏规则如下:1.答案单字写在纸上(每个字元一张纸),并且被盖起来,玩家每次猜一个英文字元(letter).2.如果这个英文 ...
- UVa 489 刽子手游戏
游戏规则,计算机想一个单词让你猜,你每次可以猜一个字母,如果单词里有那个字母,所有该字母都会显示出来,如果没有那个字母则计算机会在一副"刽子手"画上填一笔,这幅画一共需要7笔就能完 ...
- 【C/C++】例题 4-2 刽子手游戏/算法竞赛入门经典/函数和递归
[题目] 猜单词游戏. 计算机想一个单词让你猜,你每次猜一个字母. 如果单词里有那个[字母],[所有该字母会显示出来]. 如果没有那个字母,算猜错一次.[最多只能猜错六次] 猜一个已经猜过的字母也算错 ...
- UVa 489,紫书P79,刽子手游戏
题目链接:https://uva.onlinejudge.org/external/4/489.pdf 这个题很像之前的一个拓扑排序的题目,思路类似咯. 程序模块化: 每次判断一个字母,lose,wi ...
- 例题4-2 刽子手游戏(Hangman Judge, UVa 489)
#include<stdio.h> #include<string.h> int ok ,no; int left ,chance; char s[20] ,s2[20]; v ...
- 使用HTML5开发Kinect体感游戏
一.简介 我们要做的是怎样一款游戏? 在前不久成都TGC2016展会上,我们开发了一款<火影忍者手游>的体感游戏,主要模拟手游章节<九尾袭来 >,用户化身四代,与九尾进行对决, ...
- jQuery实践-网页版2048小游戏
▓▓▓▓▓▓ 大致介绍 看了一个实现网页版2048小游戏的视频,觉得能做出自己以前喜欢玩的小游戏很有意思便自己动手试了试,真正的验证了这句话-不要以为你以为的就是你以为的,看视频时觉得看懂了,会写了, ...
- Unity游戏内版本更新
最近研究了一下游戏内apk包更新的方法. ios对于应用的管理比较严格,除非热更新脚本,不太可能做到端内大版本包的更新.然而安卓端则没有此限制.因此可以做到不跳到网页或应用商店,就覆盖更新apk包. ...
随机推荐
- 【数论】数论进阶-Preknowledge
数论进阶-Preknowledge 参考资料:洛谷网校2018夏季省选基础班SX-3数论进阶课程及课件 一.整除与取整除法 1.1 定义 1.整除 \(\forall~x,y~\in~Z^+,\) 若 ...
- iOS之富文本(一)
NSAttributedString叫做富文本,是一种带有属性的字符串,通过它可以轻松的在一个字符串中表现出多种字体.字号.字体大小等各不相同的风格,还可以对段落进行格式化. 通过以下代码即可实现上面 ...
- 3 ways to download files with PowerShell
Perhaps the greatest strength of PowerShell is it's foundation on the .NET framework. The .NET frame ...
- OpenCV---其他形态学操作
一:顶帽实现(原图像与开操作图像的差值) import cv2 as cv import numpy as np def top_hat_demo(image): gray = cv.cvtColor ...
- 解决问题Can’t connect to local MySQL server through socket
不幸遇到MySQL出现ERROR 2002 (HY000): Can’t connect to local mysql server through socket ‘/tmp/mysql.sock’错 ...
- 在使用hibernate注解的时候,想对double类型的字段进行精度约束
@Column(name = "price",precision = 10,scale = 2) public double getPrice() { return price; ...
- Codeforces 221 B. Little Elephant and Numbers
B. Little Elephant and Numbers time limit per test 2 seconds memory limit per test 256 megabytes inp ...
- .Net各版本新特性
序言 C# 1.0 (2002) public interface IDateProvider { DateTime GetDate(); } 隐式接口实现 public class DefaultD ...
- opencv 高级拼接函数Stitcher
Stitcher https://docs.opencv.org/trunk/d8/d19/tutorial_stitcher.html http://blog.csdn.net/czl389/art ...
- 2017ACM暑期多校联合训练 - Team 1 1003 HDU 6035 Colorful Tree (dfs)
题目链接 Problem Description There is a tree with n nodes, each of which has a type of color represented ...