侩子手
来源:互联网 发布:淘宝推广返利网 编辑:程序博客网 时间:2024/06/16 16:15
侩子手
Description
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 tries to solve to puzzle by guessing one letter at a time.
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.”
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
| /|\
| |
| / \
_|
| |__
|___|
If the drawing of the hangman is completed before the contestant has successfully guessed all the characters of the word, the contestant loses.
If the contestant has guessed all the characters of the word before the drawing is complete, the contestant wins the game.
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.
这题有点污啊_(:з」∠)_,只要前几次答对了,后面不管答错多答多少次都可以。。。
#include <stdio.h>int main(int argc, char *argv[]){ int num,sum; char str[101],input[101],*ps,*pi,boolNum,boolNum2; while(scanf("%d",&num),num!=-1) { printf("Round %d\n",num); sum=0; boolNum2=0; scanf("%s",str); scanf("%s",input); pi=input; while(*pi!='\0') { ps=str; boolNum=0; while(*ps!='\0') { if(*ps==*pi) { *ps=' '; boolNum=1; } ps++; } if(boolNum==0) { sum++; } ps=str; while(*ps!='\0') { if(*ps!=' ') { break; } ps++; } if(*ps=='\0'&&sum<7) { printf("You win.\n"); boolNum2=1; break; } pi++; } if(sum>=7&&boolNum2==0) { printf("You lose.\n"); continue; } else if(boolNum2==0) printf("You chickened out.\n"); } return 0;}
- 侩子手
- UVa 489 侩子手游戏
- 联合国再度沦为侩子手
- 寒假刷题之8——侩子手游戏
- 巧妇能为少米之炊(2)——幽灵侩子手(LMK)
- 巧妇能为少米之炊(2)——幽灵侩子手(LMK)
- 巧妇能为少米之炊(2)——幽灵侩子手(LMK)
- JAVA从菜鸟【入门】到新手【实习】一一每日三读,视野领域的拓展,心理调节
- 排序总结系列五:快速排序
- 如何搭建SSM(SpringMvc+mybatis+Spring)java web工程
- WEB应用防火墙与数据库应用防火墙有什么区别
- Lambda表达式
- 侩子手
- npm安装cordova时警告:npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to
- 最长公共字串与最长公共子序列
- 排序总结系列六:归并排序
- C/C++/Java 中static对比
- Java NIO系列教程(二) Channel
- 并查集的例题
- 多线程学习总结(六)——实现多线程的方法之Fork/Join
- [LeetCode]--155. Min Stack