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 lzu311 at 2006-05-18 08:44:41 on Problem 1013
#include<stdio.h>
#include<string.h>
void main()
{
	int i,n,j,k;
	char s1[10],s2[10],s3[10];
	int s[20];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		memset(s,0,sizeof(s));
		for(j=1;j<=3;j++)
		{
			scanf("%s%s%s",s1,s2,s3);
			if(strcmp(s3,"even")==0)//如果even,置为1,其为真币
			{
				for(k=0;s1[k]!=0;k++)
				{
					s[s1[k]-'A']=1;
					s[s2[k]-'A']=1;
				}
			}
			if(strcmp(s3,"up")==0)
			{
				for(k=0;s1[k]!=0;k++)
				{
					if(s[s2[k]-'A']!=1)
					{
						if(s[s2[k]-'A']==2)//存在矛盾,为真币
							s[s2[k]-'A']=1;
						else
							s[s2[k]-'A']=-1;//-1标识假币为light
					}
					if(s[s1[k]-'A']!=1)
					{
						if(s[s1[k]-'A']==-1)
							s[s1[k]-'A']=1;
						else
							s[s1[k]-'A']=2;//2标识假币为heavy
					}

				}
			}
			if(strcmp(s3,"down")==0)
			{
				for(k=0;s2[k]!=0;k++)
				{
					if(s[s2[k]-'A']!=1)
					{
						if(s[s2[k]-'A']==-1)
							s[s2[k]-'A']=1;
						else
							s[s2[k]-'A']=2;
					}
					if(s[s1[k]-'A']!=1)
					{
						if(s[s1[k]-'A']==2)
							s[s1[k]-'A']=1;
						else
							s[s1[k]-'A']=-1;
					}
				}
			}
		}
		for(j=0;j<20;j++)
		{
			if(s[j]==-1)
			{
				printf("%c is the counterfeit coin and it is light.\n",j+'A');
				break;
			}
			if(s[j]==2)
			{
				printf("%c is the counterfeit coin and it is heavy.\n",j+'A');
				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