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

无赖了!A waste of time!WA!

Posted by cycpp at 2008-11-21 23:07:10 on Problem 2328
In Reply To:能测的数据都测了,就是WA,疯了 Posted by:wyu_feng at 2008-10-12 01:50:44
#include <iostream>
using namespace std;
char gg[100];
int low,high,guess;
int func()
{
	if(strcmp(gg,"too high")==0)return 1;
	else if(strcmp(gg,"too low")==0)return -1;
	else return 0;
}
int main()
{
        bool flag;
	while(1)
	{
		low=1;
		high=10;
		flag=true;
		while(1)
		{
			cin>>guess;
			if(guess==0)return 0;
			cin.get();
			cin.getline(gg,99);
			if(func()==0)
			{
				if(guess<low||high<guess)flag=false;
				if(flag)cout<<"Stan may be honest\n";
				else cout<<"Stan is dishonest\n";
				break;
			}
			else if(func()==1)high=guess-1;
			else low=guess+1;
			if(low>high)flag=false;
		}
	}
	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