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 Loger at 2004-01-11 14:09:33 on Problem 1013
#include "Stdio.h"
char flag;
char answer()
  { int letter[12][4]={0};
    int i,ii,a,b,tmp;
    char s1[4],s2[4],s[4],cmp[3];
   for(i=0;i<3;i++)
      {
       scanf("%s %s %s",s1,s2,s);
       cmp[i]=s[0];
       for(ii=0;ii<4;ii++)
           {
            letter[s1[ii]-'A'][i]=1;
            letter[s2[ii]-'A'][i]=2;
            if(cmp[i]=='e')
               {
               letter[s1[ii]-'A'][3]=1;
               letter[s2[ii]-'A'][3]=1;
               }
            }
      }

 for(flag=0;flag<2;flag++)
   {
    for(i=0;i<12;i++)
       {
         if(letter[i][3]==0)
           {
            tmp=1;
            switch(flag)
              {
                case 1:for(ii=0;(ii<3)&&(tmp);ii++)
                         {
                         if(cmp[ii]=='u'&&letter[i][ii]!=2) tmp=0;
                         if(cmp[ii]=='d'&&letter[i][ii]!=1) tmp=0;
                         }
                       break;
                case 0:for(ii=0;(ii<3)&&(tmp);ii++)
                         {
                         if(cmp[ii]=='d'&&letter[i][ii]!=2) tmp=0;
                         if(cmp[ii]=='u'&&letter[i][ii]!=1) tmp=0;
                         }
                       break;
               }
            if(tmp) return((char)i+'A');
            }
        }
   }
}
main()
{
 int n;
 scanf("%d",&n);
 while(n--)
    {
     printf("%c is the counterfeit coin and it is ",answer());
     printf(flag? "light.\n":"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