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

枚举算法显示“Presentation Error”,请求赐教!

Posted by anyone_1 at 2010-03-07 17:13:41 on Problem 1013
#include<stdio.h>
#include<string.h>
char a[4][15],b[4][15];
char p[4][15];
char c;
long n,m,i,j,k,l;
long o[15];
long u[15];
long x,y;
long N;
char ans[2][50]={" is the counterfeit coin and it is light.",
                 " is the counterfeit coin and it is heavy."};
int main()
{
 scanf("%ld",&N);
 for(;N>0;N--)
   {
    memset(o,0,sizeof(o));
    for(i=1;i<=3;i++)
      {c=getchar();
       scanf("%s",a[i]);
       c=getchar();
       scanf("%s",b[i]);
       c=getchar();
       scanf("%s",p[i]);
       if(p[i][0]=='e')
         for(j=0;j<strlen(a[i]);j++)
           o[a[i][j]-64]=o[b[i][j]-64]=1;
       }
    for(k=0;k<=1;k++)
     for(i=1;i<=12;i++)
      if(!o[i])
       {
        if(k==0)u[i]=-1;
        else    u[i]=1;
        for(l=1;l<=3;l++)
	     {
	      x=y=0;
          for(j=0;j<strlen(a[l]);j++)
           {x+=u[a[l][j]-64];
            y+=u[b[l][j]-64];}
          if(!(p[l][0]=='u'&&x>y||
               p[l][0]=='e'&&x==y||
               p[l][0]=='d'&&x<y))
          break;
         }
         u[i]=0;
	     if(l>3)
	      {putchar(i+64);
           puts(ans[k]);
           putchar(10);
           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