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 hao123 at 2005-03-18 14:34:27 on Problem 1013
#include<iostream.h>
#include<string.h>
#include<stdio.h>
void main()
{
	int num;
	cin>>num;
	for(int i=1;i<=num;i++)
	{
		int coin[3][12]={1,1,1,1,1,1,1,1,1,1,1,1
		,1,1,1,1,1,1,1,1,1,1,1,1
		,1,1,1,1,1,1,1,1,1,1,1,1};
		int sum[12]={0,0,0,0,0,0,0,0,0,0,0,0};
		
		char check[3][5]={"up","down","even"};
		char a[3][7],b[3][7],c[3][5];
		for(int j=0;j<3;j++)
		{
			int flag[12]={0,0,0,0,0,0,0,0,0,0,0,0};
			cin>>a[j]>>b[j]>>c[j];
			for(int k=0;k<3;k++)
			{
				if(strcmp(check[k],c[j])==0)
					break;
			}
			switch(k)
			{
			case 0:
				{
					for(int l=0;l<7;l++)
					{
						for(int m=0;m<12;m++)
						{
							if((b[j][l]-'A')==m)
								coin[j][m]=0;
							if((a[j][l]-'A')==m)
								coin[j][m]=1;
						}
					}
					break;
				}
				case 1:
				{
					for(int l=0;l<7;l++)
					{
						for(int m=0;m<12;m++)
						{
							if((a[j][l]-'A')==m)
								coin[j][m]=0;
							if((b[j][l]-'A')==m)
								coin[j][m]=1;
						}
					}
					break;
				}
				case 2:
				{
					for(int l=0;l<7;l++)
					{
						for(int m=0;m<12;m++)
						{
							if((a[j][l]-'A')==m)
							{coin[j][m]=1;flag[m]=1;}
							if((b[j][l]-'A')==m)
							{coin[j][m]=1;flag[m]=1;}
						}
					}
					for(int m=0;m<12;m++)
					{
						if(flag[m]==0) coin[j][m]=0;
					}
					break;
				}
			}
		}
		for(int m=0;m<12;m++)
		{
			for(j=0;j<3;j++)
			{
				sum[m]=sum[m]+coin[j][m];
			}
			if(sum[m]==0)
			{cout<<char('A'+m)<<" is the counterfeit coin and it is light."<<endl;
			break;}
		}
			
		
		for(int n=0;n<12;n++)
		{
			for(j=0;j<3;j++)
			{
				coin[j][n]=1;
			}
		}
		for(n=0;n<12;n++)
		{
			sum[n]=0;
		}
		for(j=0;j<3;j++)
		{
			int flag[12]={0,0,0,0,0,0,0,0,0,0,0,0};
			for(int k=0;k<3;k++)
			{
				if(strcmp(check[k],c[j])==0)
					break;
			}
			switch(k)
			{
			case 0:
				{
					for(int l=0;l<7;l++)
					{
						for(int m=0;m<12;m++)
						{
							if((b[j][l]-'A')==m)
								coin[j][m]=1;
							if((a[j][l]-'A')==m)
								coin[j][m]=0;
						}
					}
					break;
				}
				case 1:
				{
					for(int l=0;l<7;l++)
					{
						for(int m=0;m<12;m++)
						{
							if((a[j][l]-'A')==m)
								coin[j][m]=1;
							if((b[j][l]-'A')==m)
								coin[j][m]=0;
						}
					}
					break;
				}
				case 2:
				{
					for(int l=0;l<7;l++)
					{
						for(int m=0;m<12;m++)
						{
							if((a[j][l]-'A')==m)
							{coin[j][m]=1;flag[m]=1;}
							if((b[j][l]-'A')==m)
							{coin[j][m]=1;flag[m]=1;}
						}
					}
					for(int m=0;m<12;m++)
					{
						if(flag[m]==0) coin[j][m]=0;
					}
					break;
				}
			}
		}
		for(m=0;m<12;m++)
		{
			for(j=0;j<3;j++)
			{
				sum[m]=sum[m]+coin[j][m];
			}
			if(sum[m]==0){
					cout<<char('A'+m)<<" is the counterfeit coin and it is heavy."<<endl;
					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