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

高手帮帮忙,难道逻辑有问题?

Posted by sunkehappy at 2009-02-27 15:09:02 on Problem 2328
我觉得我把所有的情况都考虑进去了啊。为什么会WA呢?
#include <stdio.h>
#define N 100
int main( void )
{
    int sentinel ;
    float top, base, num ;
    char a[N] ;
    scanf("%f", &num ) ;
    sentinel = 0 ;
    while( num != 0 ){
    	scanf("%s", a ) ;
    	scanf("%s", a ) ;
    	if( a[0] == 'h' ){
         	top = num ;
         	if( sentinel == 1 )
         		sentinel = 1 ;
         	else
         		sentinel += 2 ;
        }
        else if( a[0] == 'l' ){
        	base = num ;
        	if( sentinel == 2 )
         		sentinel = 2 ;
         	else
         		sentinel += 2 ;
        }
        else if( a[0] == 'o' && sentinel == 0 ){
        	printf("Stan may be honest\n" ) ;
        	sentinel = 0 ;
        }
        else if( a[0] == 'o' && sentinel == 1 && num < top ){
         	printf("Stan may be honest\n" ) ;
         	sentinel = 0 ;
        }
        else if( a[0] == 'o' && sentinel == 1 && num >= top ){
         	printf("Stan is dishonest\n" ) ;
            sentinel = 0 ;
        }
        else if( a[0] == 'o' && sentinel == 2 && num > base ){
            printf("Stan may be honest\n" ) ;
            sentinel = 0 ;
        }
        else if( a[0] == 'o' && sentinel == 2 && num <= base ){
            printf("Stan is dishonest\n" ) ;
            sentinel = 0 ;
        }
        else if( a[0] == 'o' && num < top && num > base ){
        	printf("Stan may be honest\n" ) ;
        	sentinel = 0 ;
        }
        else if( a[0] == 'o' ){
            printf("Stan is dishonest\n" ) ;
            sentinel = 0 ;
        }
        scanf("%f", &num ) ;
    }
    return 0 ;
}

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