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 shenxuan6688 at 2013-05-14 22:40:18 on Problem 1002
//我已经无语了
#include<stdio.h>
#include<stdlib.h>
struct node
{   
   int data;
   int count;
}q[200000],tmp;
int main()
{
    int i,j,k=0,n,temp=0,kmp=0;
    char s[300];
    scanf("%d",&n);
    for(i=0;i<n;i++)
       {
          scanf("%s",s);
          q[k].data=0;
          q[k].count=1;
          for(j=0;s[j]!='\0';j++)
             {
                 
                  switch(s[j])
                  {
                     case '0':kmp=1;q[k].data=q[k].data*10; break;
                     case '1':kmp=1;q[k].data=1+q[k].data*10; break;  
                     case 'A':
                     case 'B':
                     case 'C':
                     case '2':kmp=1;q[k].data=2+q[k].data*10; break;
                     case 'D':
                     case 'E':
                     case 'F':
                     case '3':kmp=1;q[k].data=3+q[k].data*10; break;
                     case 'I':
                     case 'H':
                     case 'G':
                     case '4':kmp=1;q[k].data=4+q[k].data*10; break;
                     case 'L':
                     case 'J':
                     case 'K':
                     case '5':kmp=1;q[k].data=5+q[k].data*10; break;
                     case 'O':
                     case 'M':
                     case 'N':
                     case '6':kmp=1;q[k].data=6+q[k].data*10; break;
                     case 'R':
                     case 'P':
                     case 'S':
                     case '7':kmp=1;q[k].data=7+q[k].data*10; break;
                     case 'U':
                     case 'V':
                     case 'T':
                     case '8':kmp=1;q[k].data=8+q[k].data*10; break;
                     case 'X':
                     case 'Y':
                     case 'W':
                     case '9':kmp=1;q[k].data=9+q[k].data*10; break; 
                     default:break; 
                     }         
            }
          for(j=0;j<k;j++)   //k 统计个数  不相同k+1  相同count+1 
             if(q[j].data==q[k].data&&k!=0)
                  {
                      q[j].count++; 
                      temp=1;
                      break;
                  } 
           if(!temp&&kmp)
               k++;
           temp=0;
           kmp=0;
                      
       }
    
    
    for(i=0;i<k;i++)
        {
             n=i;
             for(j=i+1;j<=k;j++)
                 if(q[j].data<q[n].data)
                       n=j;
            if(n!=i)
               {
                   tmp=q[i];
                   q[i]=q[n];
                   q[n]=tmp;     
               }
        }
    temp=0;
     for(i=0;i<k;i++)
         if(q[i].count>1)
             {          
                   printf("%03d-%04d %d\n",q[i].data/10000,q[i].data%10000,q[i].count);  
                   temp=1;
             }
     if(!temp)
         printf("No duplicates.\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