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

额..忘加了#include<sting.h>

Posted by 123Go_Go_Go at 2012-09-27 21:43:33 on Problem 1013
In Reply To:带入验证法果然好使。。。大家有什么简洁巧妙地思维可以分享下。。 Posted by:123Go_Go_Go at 2012-09-27 21:38:00
> #include<iostream>
> using namespace std;
> 
> typedef struct
> {
> 	char a[14];
> 	char b[7];
> 	char record[5];
> }Dollor;
> 
> int Search(char ch[],char c)
> {
> 	int i=0;
> 	while(i<strlen(ch))
> 	{
> 		if(ch[i]==c)
> 			return 1;
> 		i++;
> 	}
> 	return 0;
> }
> 
> int main()
> {
> 	Dollor D[3];
> 	char x;
> 	int n;
> 		cin>>n;
> 	while(n--)
> 	{
> 		int i,j;
> 		bool b;
> 		for(i=0;i<3;i++)
> 		{
> 			cin>>D[i].a>>D[i].b>>D[i].record;
> 		}
> 
> 		for(x='A';x<'M';x++)
> 		{
> 			for(j=0;j<3;j++)
> 			{
>                 if(Search(D[j].a,x)==1)
> 				{
> 					if(strcmp(D[j].record,"down")!=0)
> 					{
> 						b=false;break;
> 					}
> 				}
> 				if(Search(D[j].b,x)==1)
> 				{
> 					if(strcmp(D[j].record,"up")!=0)
> 					{
> 						b=false;break;
> 					}
> 				}
> 				if(Search(D[j].a,x)==0 && Search(D[j].b,x)==0)
> 				{
> 					if(strcmp(D[j].record,"even")!=0)
> 					    break;
> 				}
> 			}
> 			if(j>=3)
> 			{
> 				cout<<x<<" is the counterfeit coin and it is light.\n";
> 				break;
> 			}
> 
> 			for(j=0;j<3;j++)
> 			{
>                 if(Search(D[j].a,x)==1)
> 				{
> 					if(strcmp(D[j].record,"up")!=0)
> 					{
> 						b=false;break;
> 					}
> 				}
> 				if(Search(D[j].b,x)==1)
> 				{
> 					if(strcmp(D[j].record,"down")!=0)
> 					{
> 						b=false;break;
> 					}
> 				}
> 				if(Search(D[j].a,x)==0 && Search(D[j].b,x)==0)
> 				{
> 					if(strcmp(D[j].record,"even")!=0)
> 					    break;
> 				}
> 			}
> 			if(j>=3)
> 			{
> 				cout<<x<<" is the counterfeit coin and it is heavy.\n";
> 				break;
> 			}
> 		}
> 	}
> 
> 	return 0;
> }
> 
> 
> 
> 
> 			
> 	

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