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 Ultramanhu at 2008-09-24 13:44:58 on Problem 1002
#include<stdio.h>
#include<string.h>
/*#include<algorithm>
using namespace std;*/
char a[100000][50];
long d[100000],e[100000];
char s[50],c;
int f;
long m,n,i,j;
long q,x,p;
int sort(long l,long r)
{    long i,j,x;
     i=l;j=r;x=e[(i+j)/2];
     while(i<=j)
     {     while(x>e[i])i++;
           while(e[j]>x)j--;
           if (i<=j)
           {    q=e[i];e[i]=e[j];e[j]=q;
                q=d[i];d[i]=d[j];d[j]=q;
                i++;
                j--;
           }
     }
     if(i<r) sort(i,r);
     if(l<j) sort(l,j);
     return 0;
}
int main()
{   scanf("%d",&n);
    /*scanf("%c",&c);*/
    for(i=1;i<=n;i++)
    {   scanf("%s",a[i]);q=1;
        while (a[i][q]!='\0') q++;\
		e[i]=0;
        for (j=0;j<=q-1;j++)
        {   c=a[i][j];
            switch(c){
            case '0':e[i]=e[i]*10;break;
            case '1':e[i]=e[i]*10+1;break;
            case '2':case 'A':case 'B':case 'C':e[i]=e[i]*10+2;break;
            case '3':case 'D':case 'E':case 'F':e[i]=e[i]*10+3;break;
            case '4':case 'G':case 'H':case 'I':e[i]=e[i]*10+4;break;
            case '5':case 'J':case 'K':case 'L':e[i]=e[i]*10+5;break;
            case '6':case 'M':case 'N':case 'O':e[i]=e[i]*10+6;break; 
            case '7':case 'P':case 'R':case 'S':e[i]=e[i]*10+7;break;
            case '8':case 'T':case 'U':case 'V':e[i]=e[i]*10+8;break;
            case '9':case 'W':case 'X':case 'Y':e[i]=e[i]*10+9;break;
            } 
            /*printf("%d",e);*/
        }
		d[i]=1;
    }
    sort(1,n);
    for(i=1;i<=n;i++)
    {p=1; while(e[i]==e[i+p]) {d[i]++;d[j]--;p++;} i=i+p-1;}
    /*sort(e,n);*/
    f=1;
    for(i=1;i<=n;i++)
       if(d[i]>=2)
       {   printf("%03ld-%04ld %ld\n",e[i]/10000,e[i]%10000,d[i]);
           f=0;
       }          
    if(f==1) printf("No duplicates.") ;     
    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