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

WA N次,求测试样例

Posted by is5land at 2010-04-18 22:10:26 on Problem 2328
#include <iostream>
#include <cstring>
using namespace std;

int num[100];
int n;

int main()
{
	char sh[20] = "too high",sl[20] = "too low",sr[20]= "right on",str[20];
	int i;
	bool sign;
	bool twice;
	while(cin>>n && n)
	{
	memset(num,0,sizeof(num));
	sign = true;
	twice = true ;
	getchar();
	gets(str);
	while((strcmp(str,sr)!=0))
	{
        if(strcmp(str,sr)==0)
              break;
		if(strcmp(str,sh)==0)
		{
			if(num[n]==-1)
			{
				twice = false;
			}
			num[n] =1;
		}
		if(strcmp(str,sl)==0)
		{
			if(num[n]==1)
			{
				twice = false;
			}
			num[n] =-1;
		}
		cin>>n;
		getchar();
		gets(str);		
	}
	if(!twice)
			cout<<"Stan is dishonest"<<endl;
	for(i= 1 ; i <n ; i++)
	{
		if( !(num[i] == 0 || num[i] ==-1 ))
		{
			cout<<"Stan is dishonest"<<endl;
			sign  = false ;
			break;
		}
	}
	if(sign)
	{
		if(num[n]!=0)
			{
			cout<<"Stan is dishonest"<<endl;
			sign  = false ;
			}
	}
	if(sign)
	{
		for(i = n +1 ; i<=10 ; i++)
			if( !(num[i] == 0 || num[i] ==1 ))
			{
			cout<<"Stan is dishonest"<<endl;
			sign  = false ;
			break;
			}
	}
	if(sign && twice)
		cout<<"Stan may be honest"<<endl;
	}
	return 0 ;
}
/*
10
too high
8
too low
8
right on

10
too high
8
too low
8
too high
7
right on

10
too high
9
too high
8
too high
1
too high
7
too high
6
too high
4
too low
3
too low
2
too low
1
too low
5
right on

*/

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