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

大牛们,帮忙看看, VC可已执行,却不能AC

Posted by huangjing1987 at 2009-08-20 22:37:04 on Problem 1013
#include<iostream>
#include<string>
using std::string;
using std::cin;
using std::cout;
using std::endl;
char left[3][7],right[3][7],result[3][5];
bool h(char x)
{
	for(int i=0;i<3;i++)
	{
		switch(result[i][0])
		{
			case 'e':if(strchr(left[i],x)!=NULL||strchr(right[i],x)!=NULL)return false;break;
			case 'u':if(strchr(left[i],x)==NULL)return false;break;
			case 'd':if(strchr(right[i],x)==NULL)return false;break;
		}
	}
	return true;
}
bool l(char x)
{
	for(int i=0;i<3;i++)
	{
		switch(result[i][0])
		{
			case 'e':if(strchr(left[i],x)!=NULL||strchr(right[i],x)!=NULL)return false;break;
			case 'u':if(strchr(right[i],x)==NULL)return false;break;
			case 'd':if(strchr(left[i],x)==NULL)return false;break;
		}
	}
	return true;
}
int main()
{
	int n;
	
	cin>>n;
	while(n)
	{
		n--;
		for(int i=0;i<3;i++)
		{
			cin>>left[i]>>right[i]>>result[i];
		}
		for(char c='A';c<='L';c++)
		{
			if(h(c))
			{cout<<c<<" is the counterfeit coin and it is heavey."<<endl;break;}
			if(l(c))
			{cout<<c<<" is the counterfeit coin and it is light."<<endl;break;}
		}
		
	}
	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