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<iostream.h> #include<string.h> #include<stdio.h> int main() { int a=0,b=11,c,flag=0; char s[40]; cin>>c; fflush(stdin); //读取回车 while(c!=0) { gets(s); if(c<1||c>10) { if(c<1&&s[4]=='h'||c>10&&s[4]=='l') { cout<<"Stan is dishonest"<<endl; flag=1; } //else 继续;;; } if(flag==1) goto lp; //判断了不诚实后,就等待着right on 的出现。 if(s[4]=='h') { if(c<=a+1) { flag=1; } else if(c<=b) b=c; } if(s[4]=='l') { if(c>=b-1) { flag=1; } else if(c>=a) a=c; } lp: if(s[4]=='t') { if(c>a&&c<b&&flag==0) cout<<"Stan may be honest"<<endl; else cout<<"Stan is dishonest"<<endl; flag=0; //碰到一个right on后,初始化,后接着继续判别。 a=0;b=11; } cin>>c; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator