Guessing Game
題目描述
Stan and Ollie are playing a guessing game. Stan thinks of a number between 1 and 10 and Ollie guesses what the number might be. After each guess, Stan indicates whether Ollie's guess is too high, too low, or right on.
After playing several rounds, Ollie has become suspicious that Stan cheats; that is, that he changes the number between Ollie's guesses. To prepare his case against Stan, Ollie has recorded a transcript of several games. You are to determine whether or not each transcript proves that Stan is cheating.
Standard input consists of several transcripts. Each transcript consists of a number of paired guesses and responses. A guess is a line containing single integer between 1 and 10, and a response is a line containing "too high", "too low", or "right on". Each game ends with "right on". A line containing 0 follows the last transcript.
For each game, output a line "Stan is dishonest" if Stan's responses are inconsistent with the final guess and response. Otherwise, print "Stan may be honest".
樣例輸入
10 too high 3 too low 4 too high 2 right on 5 too low 7 too high 6 right on 0
樣例輸出
Stan is dishonest Stan may be honest
題意:
斯坦和奧利在玩猜謎遊戲。斯坦想到了1到10之間的數字,奧利猜測這個數字可能是什麼。在每次猜測之後,斯坦都指出奧利的猜測是太高、太低還是正確。
打了幾回合後,奧利懷疑斯坦作弊,也就是說,他在奧利的猜測之間改變了數字。為了準備他對斯坦的案子,奧利錄下了一些比賽的錄音。你要確定每份成績單是否都能證明斯坦在作弊。
標準輸入由幾份成績單組成。每份成績單都有一些配對的猜測和反應。a猜是包含1與10之間的單整數的行,而一個響應則是包含“過高”、“過低”或“正確”的行。每個遊戲都以“正確”結尾。在最後的成績單後面有一行包含0。
對於每個遊戲,如果斯坦的反應與最後的猜測和反應不一致,那麼輸出一行“斯坦是不誠實的”。否則,列印“斯坦可能是誠實的”。
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int a;
char ans[10];
while(1)
{
int Max = 100;
int Min = 0;
cin>>a;
if(a == 0)
break;
getchar();
gets(ans);
while(1)
{
if(strcmp(ans,"right on") == 0)
break;
if(strcmp(ans,"too high") == 0&&a<Max)
Max = a;
if(strcmp(ans,"too low") == 0&&a>Min)
Min = a;
cin>>a;
getchar();
gets(ans);
}
if( a > Min && a < Max )
printf("Stan may be honest\n");
else
printf("Stan is dishonest\n");
}
return 0;
}
相關文章
- Card GameGAM
- Wooden GameGAM
- Shop GameGAM
- Infinite Card GameGAM
- game development -- flowGAMdev
- Fast Car GameASTGAM
- Jump-gameGAM
- HDU 1729 Stone GameGAM
- C. Game MasterGAMAST
- C. Game on PermutationGAM
- E. Wooden GameGAM
- D. Shop GameGAM
- This is the easiest to observe during the gameGAM
- FZU 2275 Game (KMP)GAMKMP
- Switch Game HDU - 2053GAM
- Jump Game(C++)GAMC++
- Shooter Game User Interface StarterGAM
- [LeetCode] 55. Jump GameLeetCodeGAM
- D. Soldier and Number GameGAM
- C. MEX Game 1GAM
- Game Jam與椰島GAM
- TGDC | Evolving AAA Game DevelopmentGAMdev
- Leetcode 292. Nim GameLeetCodeGAM
- Dragon Tiger Cattle Cattle GameGoGAM
- 都說自己玩的是dead game,但究竟誰才是真的dead game?GAM
- wordle game 猜字遊戲GAM遊戲
- Codeforces_943_D_Permutation GameGAM
- CF2006A Iris and Game on the TreeGAM
- Lecture 02 Layered Architecture of Game EngineGAM
- 【博弈論】HDU - 7216 Triangle GameGAM
- [LeetCode] 45. Jump Game IILeetCodeGAM
- CF482C Game with StringsGAM
- ESPN NBA Basketball was the one franchise gameGAM
- 【Leetcode】1690. Stone Game VIILeetCodeGAM
- Cognitive Flow: The Psychology of Great Game DesigGAM
- Atcoder nomura2020F Sorting GameGAM
- [Tkey] CodeForces 1267G Game RelicsGAM
- noip模擬31[time·game·cover]GAM