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 ericsummer at 2005-12-18 11:09:18 on Problem 2328
#include <stdio.h>
#include <string.h>
#include <iostream.h>

char s[100];

int n;

int main()
{
	while(cin>>n && n!=0)
	{
		int a=1;
		int b=10;
		int flag=1;
		while(1)
		{
			gets(s);
			if(strcmp(s,"right on")==0)
			{
				if(a>b||a>n||b<n)
					flag=0;
				break;
			}
		
		    if(flag==1)
			{
			if(strcmp(s,"too high")==0&&n<=b)
			{
				b=n-1;
			}
			else
				if(strcmp(s,"too low")==0&&n>=a)
				{
					a=n+1;
				}
		    if(a>b)flag=0;
			}	
			cin>>n;
		}
		if(flag==1)
			printf("Stan may be honest\n");
		else
			printf("Stan is dishonest\n");
	}
	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