| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WAWAWAWAWAway?help!!!/*pku 2328 Guessing Game 051210 WA */
#include<stdio.h>
int high,low;
int guess;
int honest;
char response [10];
int output (int honest)
{
if(honest)
printf("Stan may be honest\n");
else
printf("Stan is dishonest\n");
high=10,low=1,honest=1;
}
int main()
{
int high,low;
int guess;
int honest;
char response [10];
for(high=10,low=1,honest=1;scanf("%d",&guess);)
{
if(!guess)
return 0;
scanf("%*s%s", response);
switch(response[0])
{
case 'h':
high=(guess<high)?guess:high;
break;
case 'l':
low=(guess>low)?guess:low;
break;
case 'o':
if((guess<=low)||(guess>=high)||high<=low+1)
honest=0; /*和high小于low+1的情况应该已经包含在前面两种里面了吧*/
output(honest);
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator