| ||||||||||
| 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 | |||||||||
Re:WR,高求手指点.........感激不尽In Reply To:Re:感谢高手指点.........感激不尽 Posted by:jinweiliang at 2009-04-15 13:01:05 > //#include "stdafx.h"
> #include <stdio.h>
> #include <string.h>
> int main(int argc, char* argv[])
> {
> int a=0,b=11,c=0,n,low=0,high=11;
>
> //freopen("2328.txt","r",stdin);
>
> while(1)
> {
> scanf("%d",&n);getchar ();
>
> if(n==0)
> break;
>
> char s[21];
>
> gets(s);
>
> if(strcmp(s,"too high")==0)//每输入一次就缩小b=high的范围
> {
> if(high>=n)
> high=n;
> b=high;//printf("b=%d\n",b);
>
> }
> else if(strcmp(s,"too low")==0)//每输入一次就缩小a=low的范围
> {
> if(low<=n)
> low=n;
> a=low;//printf("a=%d\n",a);
> }
> else if(strcmp(s,"right on")==0)//判断c是否在a b之间;
> {
> c=n;//printf("c=%d\n",c);
> for(int i=a+1;i<b;i++)
> if(i==c)
> {
> printf("Stan may be honest\n");//c是在a b之间;
> goto loop;
> }
>
> printf("Stan is dishonest\n");//c不在a b之间;
> loop:;
>
> low=0,high=11;
> }
> }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator