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

为什么总WA 那位帮看一下(新手)谢谢!!(代码)

Posted by wuchunlong at 2009-02-27 21:03:31 on Problem 1013
#include <iostream>
using namespace std;
int main()
{
    int coin[12],i,count,m1,m2,k,c[12];
    char a[6][8],b[3][5];
    for(i=0;i<12;i++)
        coin[i]=0;
       cin>>count; 
      while(count)
      {
      	  for(i=0;i<12;i++) { coin[i]=c[i]=0; }
      	  cin>>a[0]>>a[1]; 
      	    cin>>b[0];  getchar();
      	  cin>>a[2]>>a[3];
      	    cin>>b[1];  getchar();
      	  cin>>a[4]>>a[5];
      	    cin>>b[2];  
      	  for(int j=0;j<3;j++)
      	   {
      	   	  for(k=0;k<8&&a[j][k];k++) 
      	      { 
      	    	    m1=a[2*j][k]-'A';    
      	    	    m2=a[2*j+1][k]-'A';  
      	        if(b[j][0]=='e') { coin[m1]=2; coin[m2]=2; c[m1]=c[m2]=0;}
      	        else 
      	    		{
      	    			if(b[j][0]=='d')  
      	    			 {
      	    			 	if(coin[m1]!=2)  { if(!coin[m1]) {coin[m1]=4; c[m1]++;} else if(coin[m1]==5) {coin[m1]=2;  c[m1]=0;} else if(coin[m1]==4) c[m1]++;}
      	    			 	if(coin[m2]!=2)  { if(!coin[m2]) {coin[m2]=5; c[m2]++;} else if(coin[m2]==4) {coin[m2]=2;  c[m2]=0;} else if(coin[m2]==5) c[m2]++;}
      	    			 }
      	    			else if(b[j][0]=='u')
      	    			  {
      	    			  	 if(coin[m1]!=2)  { if(!coin[m1]) {coin[m1]=5; c[m1]++;} else if(coin[m1]==4) {coin[m1]=2; c[m1]=0;} else if(coin[m1]==5) c[m1]++;}
      	    			 	 if(coin[m2]!=2)  { if(!coin[m2]) {coin[m2]=4; c[m2]++;} else if(coin[m2]==5) {coin[m2]=2; c[m2]=0;} else if(coin[m2]==4) c[m2]++;}
      	    			  } 
      	    			 	
      	    		}	 	
      	      } 		         
      	   }    
      	   int max=c[0],n=0; 	   
      	  for(k=0;k<12;k++)  
      		if(c[k]>max) {max=c[k]; n=k;}
           char ch='A'+n;
           if(coin[n]==4)  cout<<ch<<" is the counterfeit coin and it is light."<<endl;
           else            cout<<ch<<" is the counterfeit coin and it is heavy."<<endl;
      	count--;
      } 	 
    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