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 |
两边加法则小的不能比大的大大的不能比小的小#include <stdio.h> #include <string.h> int main() { int n,min,max,flag; char guess[20]; while(1) { flag=0; min=0; max=11; while(scanf("%d",&n)!=EOF&&n) { gets(guess); if(!strcmp(guess,"right on")) break; else if(!strcmp(guess,"too high")&&!flag) { if(n<=max) { max=n; max--; } if(max<min) flag=1; } else if(!strcmp(guess,"too low")&&!flag) { if(n>=min) { min=n; min++; } if(min>max) flag=1; } } if(n==0) break; if(flag||n>max||n<min) printf("Stan is dishonest"); else printf("Stan may be honest"); printf("\n"); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator