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

两边加法则小的不能比大的大大的不能比小的小

Posted by chenxuan123456789 at 2012-07-30 09:45:04 on Problem 2328
#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:
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