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 |
高手帮帮忙,难道逻辑有问题?我觉得我把所有的情况都考虑进去了啊。为什么会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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator