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

究竟错哪了?实在看不出啊!!!

Posted by datouchong at 2006-02-25 12:10:02 on Problem 1013
#include<iostream.h>
#include<string.h>
#include<stdio.h>
char left[3][7],right[3][7],result[3][7];
int isleft(int i,char x){ 
      int k,p;
	  p=strlen(left[i]);
      for(k=0;k<p;k++) 
              if(left[i][k]==x) 
				  return 1;
			  
				  return 0;                  
	}
int isright(int i,char x){
		int k,p;
		p=strlen(right[i]);
		for(k=0;k<p;k++)
			if(right[i][k]==x)
				return 1;
			
				return 0;
	}
int light(char x){
		int j;
		for(j=0;j<3;j++)
		switch(result[j][0]){
		case 'u':if(!isright(j,x))
					 return 0;break;
		case 'e':if(isright(j,x)||isleft(j,x))
					 return 0;break;
		case 'd':if(!isleft(j,x))
						return 0;break;
		}
		return 1;
	}
int heavy(char x){
		int j;
		for(j=0;j<3;j++)
		switch(result[j][0]){
		case 'u':if(!isright(j,x))
					 return 0;break;
		case 'e':if(isright(j,x)||isleft(j,x))
					 return 0;break;
		case 'd':if(!isleft(j,x))
						return 0;break;
		}
		return 1;
	}
void main()
{
	char c;
	int i,j,k;
	cin>>j;
	for(k=0;k<j;k++){
	for(i=0;i<3;i++)
		cin>>left[i]>>right[i]>>result[i];
	for(c='A';c<='L';c++){
		if(light(c)){
			cout<<c<<" is the counterfeit coin and it is light.\n";
			
		}
		else
			if(heavy(c)){
				cout<<c<<" is the counterfeit coin and it is heavy.\n";
				
			}
		}
	}
}

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