Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WAWAWAWAWAway?help!!!

Posted by ning at 2005-12-11 09:52:48 on Problem 2328
/*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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator