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 williamzl at 2005-07-25 21:00:12 on Problem 1053
#include <stdio.h>
#include <string.h>
int main()
{
 int i,flag,count,j,k,f,t,control;
 char line[20];
 char a[300][4];
 
 i=0;
 flag=0;
 count=0;
 control=0;
 while (true)
 {
   char *s=gets(line);
   if (strlen(line)!=0)
   {  
    sscanf(line,"%c%c%c%c",&a[i][0],&a[i][1],&a[i][2],&a[i][3]);
    i=i+1;
   }    
  if (s==NULL || line[0]==0)
     { 
      printf ("\nCARDS:  ");
       for (j=0;j<i;j++) 
       { 
        for (k=0;k<4;k++)
          printf("%c",a[j][k]);
        printf (" ");
       }     
      printf ("\nSETS:   ");
       
       for (j=0;j<i;j++) 
         for (k=j+1;k<i;k++)
           for (f=k+1;f<i;f++)
             {
              if ((a[j][0]!=a[k][0]&&a[j][0]!=a[f][0]&&a[k][0]!=a[f][0])||(a[j][0]==a[k][0]&&a[j][0]==a[f][0]&&a[k][0]==a[f][0])) flag=flag+1; 
              if ((a[j][1]!=a[k][1]&&a[j][1]!=a[f][1]&&a[k][1]!=a[f][1])||(a[j][1]==a[k][1]&&a[j][1]==a[f][1]&&a[k][1]==a[f][1])) flag=flag+1; 
              if ((a[j][2]!=a[k][2]&&a[j][2]!=a[f][2]&&a[k][2]!=a[f][2])||(a[j][2]==a[k][2]&&a[j][2]==a[f][2]&&a[k][2]==a[f][2])) flag=flag+1; 
              if ((a[j][3]!=a[k][3]&&a[j][3]!=a[f][3]&&a[k][3]!=a[f][3])||(a[j][3]==a[k][3]&&a[j][3]==a[f][3]&&a[k][3]==a[f][3])) flag=flag+1; 
              if (flag==4) 
              {
                count++;
                if (count==1)printf ("%d.  ",count);else printf ("        %d.  ",count);
                for (t=0;t<4;t++)
                 printf("%c",a[j][t]);
                printf (" "); 
                for (t=0;t<4;t++)
                 printf("%c",a[k][t]); 
                printf (" "); 
                for (t=0;t<4;t++)
                 printf("%c",a[f][t]);
                printf ("\n");  
               } 
               
               flag=0;
             }
       if  (count!=0)    printf ("\n");       
       if (count==0) printf ("*** None Found ***\n\n");
       count=0;
       i=0;
       flag=0;
  } 
   if (s==NULL) break;

}       
           
             
}               

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