| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么会OUTPUT LIMIT EXCEED啊 查不出来了.高手帮帮.(附代码)#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator