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 0809114213 at 2010-08-18 01:25:48 on Problem 1013
#include<stdio.h>
#include<string.h>

char right[3][7],lift[3][7],hehe[3][5];

int qing(char);
int zhong(char);

void main(void)
{
	int n,i;
	char ch;
	scanf("%d",&n);
	while(n--)
	{
		memset(right,'\0',sizeof(right));
		memset(lift,'\0',sizeof(lift));
		memset(hehe,'\0',sizeof(hehe));
		for(i=0;i<=2;i++)
		scanf("%s %s %s",right[i],lift[i],hehe[i]);
		for(ch='A';ch<='L';ch++)
		{
			if(qing(ch))
			{
				printf("%c is the counterfeit coin and it is light.\n", ch);
				break;
			}
			if(zhong(ch))
			{
				printf("%c is the counterfeit coin and it is heavy.\n", ch);
				break;
			}
		}
	}
}

int qing(char a)
{
	int i;
	for(i=0;i<=2;i++)
		switch(hehe[i][0])
	{
		case 'u':if(strchr(lift[i],a)==NULL)return 0;
			break;
        case 'e':if(strchr(lift[i],a)!=NULL||strchr(right[i],a)!=NULL)return 0;
			break;
		case 'd':if(strchr(right[i],a)==NULL)return 0;
			break;	
	}
	return 1;
}

int zhong(char a)
{
	int i;
	for(i=0;i<=2;i++)
		switch(hehe[i][0])
	{
		case 'u':if(strchr(right[i],a)==NULL)return 0;
			break;
        case 'e':if(strchr(lift[i],a)!=NULL||strchr(right[i],a)!=NULL)return 0;
			break;
		case 'd':if(strchr(lift[i],a)==NULL)return 0;
			break;	
	}
	return 1;
}

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