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

为什么会OUTPUT LIMIT EXCEED啊 查不出来了.高手帮帮.(附代码)

Posted by ambyalWang at 2006-07-27 23:51:00 on Problem 1002
#include <stdio.h>
//#include <conio.h>
#include <string.h>
#include <stdlib.h>

const char table[25]="222333444555666777888999";
char ch[16];
struct phone{ 
   char cc;
   char str[9]; 
}s[100001]; 

int cmp( const void *a , const void *b ) 
{
    return strcmp((*(phone *)a).str,(*(phone *)b).str); 
} 


void input(int n)
{
     int i,j,cou;
     for(i=0;i<n;i++)
     {
         cou=0;
         scanf("%s",ch);
         for(j=0;j<16;j++)
         {
             if(cou>=8) break;
             if(cou==3) s[i].str[cou++]='-';
             if(ch[j]=='-') continue;
             if(ch[j]>='A'&&ch[j]<='P')
                 s[i].str[cou++]=table[ch[j]-'A'];
             if(ch[j]>='R'&&ch[j]<='Y')
                 s[i].str[cou++]=table[ch[j]-'A'-1];
             if(ch[j]>='0'&&ch[j]<='9')
                 s[i].str[cou++]=ch[j];
         }
     }     
}

int main()
{
    int n;
    int i,j;
    int count,flag=0;
    
    scanf("%d",&n);
    input(n);
    qsort(s,n,sizeof(s[0]),cmp);
    
    i=0;
    while(i<n-1)
    {
        count=1;
        for(j=i+1;j<n;j++)
        {
            if(strcmp(s[i].str,s[j].str)!=0){  i=j;break; }
            count++;
        }
        if(count>1)
        {
            printf("%s %d\n",s[j-1].str,count);
            flag=1;
        }
    }
    if(!flag) printf("No duplicates.");
    
    //getch();
    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