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

请各位老大帮忙看看!为什么老是wrong

Posted by 00448295 at 2005-03-16 17:43:55 on Problem 1013
#include<iostream.h>
void main()
{
	char left[3][7],right[3][7],result[3][7];
	int a[12],i,j,time[12],num,k;
	cin>>num;
	for(k=0;k<num;k++)
	{
	for(j=0;j<12;j++)
	{
		a[j]=0;
		time[j]=0;
	};
	for(i=0;i<3;i++)
		cin>>left[i]>>right[i]>>result[i];
	for(i=0;i<3;i++)
	{
		if(result[i][0]=='e')
		{
			for(j=0;left[i][j]!='\0';j++)
			{
				a[left[i][j]-'A']=1;
				
			}
			for(j=0;right[i][j]!='\0';j++)
			{
				
				a[right[i][j]-'A']=1;
			}
		};
	};
	for(i=0;i<3;i++)
	{
		for(j=0;left[i][j]!='\0';j++)
		{
			if(a[left[i][j]-'A']==0&&result[i][0]!='e')//2=light;3=heavy;
			{
				if(result[i][0]=='u')a[left[i][j]-'A']=3;
				if(result[i][0]=='d')a[left[i][j]-'A']=2;
			}
		}
		for(j=0;right[i][j]!='\0';j++)
		{
			if(a[right[i][j]-'A']==0&&result[i][0]!='e')
			{
				if(result[i][0]=='u')a[right[i][j]-'A']=2;
				if(result[i][0]=='d')a[right[i][j]-'A']=3;
			}
		}
		
	};
	for(i=0;i<3;i++)
	{
		if(result[i][0]=='u')
		{
			for(j=0;left[i][j]!='\0';j++)
			{
				if(a[left[i][j]-'A']==2)a[left[i][j]-'A']=1;
			}
			for(j=0;right[i][j]!='\0';j++)
			{
				if(a[right[i][j]-'A']==3)a[right[i][j]-'A']=1;
			}
			
		}
		if(result[i][0]=='d')
		{	
			
			for(j=0;left[i][j]=='\0';j++)
			{
				if(a[left[i][j]-'A']==3)a[left[i][j]-'A']=1;
			}
			for(j=0;right[i][j]=='\0';j++)
			{
				if(a[right[i][j]-'A']==2)a[right[i][j]-'A']=1;
			}
		}
	};
	for(i=0;i<3;i++)
	{
		for(j=0;left[i][j]!='\0';j++)
		{
			if(a[left[i][j]-'A']>1)
				time[left[i][j]-'A']++;
		}
		for(j=0;right[i][j]!='\0';j++)
		{
			if(a[right[i][j]-'A']>1)
				time[right[i][j]-'A']++;
		}
	};
	int temp=0;
	for(i=0;i<12;i++)
	{
		if(time[temp]<=time[i])
			temp=i;
		else
			a[i]=0;
	};
	if(a[temp]==2)cout<<(char)(temp+'A')<<" is the counterfeit coin and it is light.\n";
	if(a[temp]==3)cout<<(char)(temp+'A')<<" 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