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.,...

Posted by joyan at 2007-03-03 14:39:59 on Problem 1013
#include<iostream.h>
#include<string.h>

int main(){
	char szLeft[3][12],szRight[3][12],szResult[3][7];
	char cNow;
	int n,i,j;
	cin>>n;
	for( i = 0; i < n; i++){
		for( j = 0; j < 3 ;j++){
			cin>>szLeft[j]>>szRight[j]>>szResult[j];
		}
		for(cNow = 'A'; cNow <= 'L'; cNow++){
			for( j = 0; j < 3 ;j++){
				if(szResult[j][0] == 'u' && !strchr(szLeft[j],cNow)) break;
				if(szResult[j][0] == 'd' && !strchr(szRight[j],cNow)) break;
				if(szResult[j][0] == 'e' 
					&& (strchr(szLeft[j],cNow) ||strchr(szRight[j],cNow))) break;
			}
			if(j == 3){
				cout<<cNow<<" is the counterfeit coin and it is heavy."<<endl;
				return 0;
			}
			for( j = 0; j < 3 ;j++){
				if(szResult[j][0] == 'd' && !strchr(szLeft[j],cNow)) break;
				if(szResult[j][0] == 'u' && !strchr(szRight[j],cNow)) break;
				if(szResult[j][0] == 'e' 
					&& (strchr(szLeft[j],cNow) ||strchr(szRight[j],cNow))) break;
			}
			if(j == 3){
				cout<<cNow<<" 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