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

应该是标准头文件里已经使用了left,right这几个变量名

Posted by number at 2006-07-16 16:17:36 on Problem 1013
In Reply To:枚举法,帮偶排一下错吧,可能很弱智,但自己发现不了,compile不了 Posted by:steppewolf at 2006-07-16 16:09:27
> #include <iostream>
> #include <string.h>
> 
> using namespace std;
> 
> char c;
> char left[3][7],right[3][7],status[3][10];
> 
> int inLeft(int i,char x)
> {
> 	for(int j=0;j<strlen(left[i]);j++)
> 	{
> 		if(left[i][j] == x)
> 			return 1;
> 	}
> 	return 0;
> }
> int inRight(int i,char x)
> {
> 	for(int j=0;j<strlen(right[i]);j++)
> 	{
> 		if(right[i][j] == x)
> 			return 1;
> 	}
> 	return 0;
> }
> int isLight(char c)
> {
> 	for(int i=0;i<3;i++)
> 	{
> 		switch(status[i][0])
> 		{
> 		case 'u':
> 			if(!inRight(i,c)) return 0;
> 			break;
> 		case 'd':
> 			if(!inLeft(i,c)) return 0;
> 			break;
> 		case 'e':
> 			if(inRight(i,c) || inLeft(i,c)) return 0;
> 			break;
> 		}
> 	}
> 	return 1;
> }
> int isHeavy(char c)
> {
> 	for(int i=0;i<3;i++)
> 	{
> 		switch(status[i][0])
> 		{
> 		case 'u':
> 			if(!inLeft(i,c)) return 0;
> 			break;
> 		case 'd':
> 			if(!inRight(i,c)) return 0;
> 			break;
> 		case 'e':
> 			if(inRight(i,c) || inLeft(i,c)) return 0;
> 			break;
> 		}
> 	}
> 	return 1;
> }
> int main()
> {
> 	int n;
> 	cin>>n;
> 	while(n--)
> 	{
> 
> 		for(int i=0;i<3;i++)
> 		{
> 			cin>>left[i]>>right[i]>>status[i];
> 		}
> 		for(;c>='A'&&c<='L';c++)
> 		{
> 			if(isLight(c))
> 			{
> 				cout<<c<<" is the counterfeit coin and it is light."<<endl;
> 				break;
> 			}
> 			if(isHeavy(c))
> 			{
> 				cout<<c<<" is the counterfeit coin and it is heavy."<<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