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

Re:感谢高手指点.........感激不尽

Posted by jinweiliang at 2009-04-15 13:01:05 on Problem 2328
//#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:
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