poj 2328 Guessing Game
2011-07-31 01:00
357 查看
Guessing Game
Description
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.
Input
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.
Output
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".
Sample Input
Sample Output
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 11620 | Accepted: 4107 |
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.
Input
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.
Output
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".
Sample Input
10 too high 3 too low 4 too high 2 right on 5 too low 7 too high 6 right on 0
Sample Output
Stan is dishonest Stan may be honest
AC code:
#include
<stdio.h>
typedef
struct
{
int max;
int min;
}
guess;
int
main()
{
int s;
char a[12];
guess n;
n.max=11,n.min=0;
while(1)
{
scanf("%d",&s);
getchar();
if(s==0)
break;
gets(a);
if(a[4]=='h')
{
if(s<=n.max)
n.max=s;
}
else if(a[4]=='l')
{
if(s>=n.min)
n.min=s;
}
else if(a[0]=='r')
{
if(n.min<s&&s<n.max)
{
printf("Stan may be honest\n");
n.max=11,n.min=0;
}
else
{
printf("Stan is dishonest\n");
n.max=11,n.min=0;
}
}
}
return 0;
}
水题,不过还是有些地方要注意。WA了1次。。
相关文章推荐
- POJ 2328 Guessing Game(一道让我想哭的水题!)
- poj2328 Guessing Game
- POJ 2328 Guessing Game
- POJ 2328 Guessing Game(我的水题之路——猜数字测谎)
- POJ 2328 Guessing Game
- poj 2328 Guessing Game
- POJ 2328 Guessing Game G++
- zoj 1926 || poj 2328 Guessing Game(水~)
- POJ 2328 Guessing Game(水~)
- POJ 2328 Guessing Game
- Poj 2328 Guessing Game(猜数字游戏)
- Poj 2328 Guessing Game(猜数字游戏)
- poj 2328 Guessing Game
- Guessing Game解题报告 (pku 2328)
- (Relax ST1.16)POJ 3589 Number-guessing Game(求连个字符串中相同的字符有多少个和同位置&&同字符的字符个数有多少个)
- POJ 3589 Number-guessing Game(水~)
- poj 3589 Number-guessing Game
- POJ 3589 Number-guessing Game(简单题)
- POJ 3589 Number-guessing Game(简单题)
- 【贪心】【poj 4028】GCD Guessing Game