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

求高手解答,这个程序为什么在DEV-C++能通过,在POJ上不能通过??

Posted by d8660091 at 2010-05-07 21:22:56
#include<stdio.h>
#include<string.h>
char inverse1(char a)                   
{
    switch(a)
    {
        case 'A':
        case 'B':
        case 'C':return '2';break;
        case 'D':
        case 'E':
        case 'F':return '3';break;
        case 'G':
        case 'H':
        case 'I':return '4';break;
        case 'J':
        case 'K':
        case 'L':return '5';break;
        case 'M':
        case 'N':
        case 'O':return '6';break;
        case 'P':
        case 'R':
        case 'S':return '7';break;
        case 'T':
        case 'U':
        case 'V':return '8';break;
        case 'W':
        case 'X':
        case 'Y':return '9';break;
        default: return a;break;
    }
}

void inverse2(char a[])                    
{
    char b[15];
    int i=0,j=0;
    while(a[i]!=0)
    {
        if(a[i]=='-') {i++;continue;}
        b[j++]=inverse1(a[i]);
        if(j==3) b[j++]='-';
        i++;
    } 
    b[j]=0;
    i=0;j=0;
    while(b[i]!=0)
    {
        a[i++]=b[i];
    }
    a[i]=0;
}

int check(char *a,char (*s)[15],int amount)   
{
    int i,j=0;
    for(i=0;i<amount;i++)
    {if (strcmp(a,s[i])==0)j++;}
    return j;   
}

void tiaozheng(char (*a)[15],int amount)
{
    char c[15];
    int i,j;
    for(i=0;i<amount;i++)
    {
        for(j=0;j<i;j++)
        if(a[i][0]!=0&&strcmp(a[i],a[j])<0) 
        {
            strcpy(c,a[i]);
            strcpy(a[i],a[j]);
            strcpy(a[j],c);
        }
    }
}


main()
{
    int i=0;
    int j=0;
    int amount;
    scanf("%d",&amount);
    char st[amount][15];
    char st1[amount][15];
    for(i=0;i<amount;i++)
    {
        for(j=0;j<15;j++)
        st1[i][j]=0;
    }
    j=0;
    
    for(i=0;i<amount;i++)
    {
        scanf("%s",&st[i]);
    }
    for(i=0;i<amount;i++)
    {
        inverse2(st[i]);
    }
    for(i=0;i<amount;i++)
    {
        if(check(st[i],st,amount)>1)
        {
                if(check(st[i],st1,amount)==0)
                {
                    strcpy(st1[j++],st[i]);
                }
        }
    }
    printf("\n\n");
    if (st1[0][0]==0) printf("No duplicates");
    else 
    {
        tiaozheng(st1,amount);
        i=0;
        while(st1[i][0]!=0)
        {
            printf("\n%s %d",st1[i],check(st1[i],st,amount));
            i++;
        }
    }
    printf("\n\n");
    system("pause");
}

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