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 crazyyangdan at 2011-07-21 17:04:18 on Problem 1013
#include<iostream>
#include<string>
using namespace std;

int s[12];

int main()
{
	int N,i;
	cin>>N;
   

	while(N--)
	{
	  memset(s,0,sizeof(s));
      int k=3;
      while(k--)
	  {
		  char a[7],b[7],c[6];
		  cin>>a>>b>>c;

	     if(strcmp(c,"even")==0) 
		 {
		   for(i=0;i<strlen(a);i++)
		   {
			  s[a[i]-'A']=1;
              s[b[i]-'A']=1;
		   }
   
		 }

		 if(strcmp(c,"up")==0) 
		 {
		   
		     for(i=0;i<strlen(a);i++)
			 {
				 if(s[a[i]-'A']!=1)  
				 {
					 if(s[a[i]-'A']==-1)     s[a[i]-'A']=1;
					 else   s[a[i]-'A']=2;
				 }
			     if(s[b[i]-'A']!=1)
				 {
					 if(s[b[i]-'A']==2 )     s[b[i]-'A']=1;
					 else   s[b[i]-'A']=-1;
				 }

			 }
		   
		  }
           
		  if(strcmp(c,"down")==0) 
		 {
		   
		     for(i=0;i<strlen(a);i++)
			 {
			    if(s[a[i]-'A']!=1)  
				{
				  if(s[a[i]-'A']==2)     s[a[i]-'A']=1;
					 else   s[a[i]-'A']=-1;
				}
			    if(s[b[i]-'A']!=1)  

				{
					 if(s[b[i]-'A']==-1 )     s[b[i]-'A']=1;
					 else   s[b[i]-'A']=2;
				}

			 }
		   
		  }
          

		  
		}
	  int sum=0;  int p=0,q=0;
   
      for(i=0;i<12;i++)
	  {
		  if(s[i]==-1)  { sum++;  p=i+1; }
			 
		  if(s[i]==2)    {sum++;  q=i+1; }
			 
	  }
	  if(sum==1)  
	  {
	      if(p)  cout<<(char)('A'+p-1)<<" is the counterfeit coin and it is light.\n";
	      if(q)  cout<<(char)('A'+q-1)<<" is the counterfeit coin and it is heavy.\n";
	  }

	}
     
	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