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 IC0590501427 at 2005-12-21 20:44:32 on Problem 1013
#include<stdio.h>
#include<string.h>
char s1[3][7],s2[3][7],s[3][7];

int left(int i,char c){
	for(int j=0;s1[i][j]!='\0';j++){
		if(s1[i][j]==c) return 1;
	}
	return 0;
}

int right(int i,char c){
	for(int j=0;s2[i][j]!='\0';j++){
		if(s2[i][j]==c) return 1;
	}
	return 0;
}
int light(char c){
	for(int i=0;i<3;i++){
		switch(s[i][0]){
		case 'u':if(!right(i,c)) return 0;
			      else break;
		case 'e':if(left(i,c)||right(i,c)) return 0;
			      else break;
		case 'd':if(!left(i,c)) return 0;
			      else break;
		}
	}
		return 1;
	
}

int heavy(char c){
	for(int i=0;i<3;i++){
		switch(s[i][0]){
		case 'u':if(!left(i,c)) return 0;
		         else break;
		case 'e':if(left(i,c)||right(i,c)) return 0;
		         else break;
		case 'd':if(!right(i,c)) return 0;
		         else break;
		}
	}
		return 1;
	
}	
void main(){
	int n;
	scanf("%d",&n);
	for(int k=0;k<3;k++){
		scanf("%s %s %s",s1[k],s2[k],s[k]);
	}
	for(char c='A';c<='L';c++){
			if(light(c)){
				printf("%c is the counterfeit coin and it is light.\n",c);
				break;
			}
			else if(heavy(c)){
				printf("%c is the counterfeit coin and it is heavy.\n",c);
				break;
			}
	}
}
		
	










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