| ||||||||||
| 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 | |||||||||
诶,TLE了#include<stdio.h>
char *f(char a[])
{
int i=0,j=0;
char f[20];
while(*(a+i)!='\0')
{
switch(a[i])
{
case '1':
*(f+j)='1';i++;j++;break;
case 'A':case 'B':case 'C':case '2':
*(f+j)='2';i++;j++;break;
case 'D':case 'E':case 'F':case '3':
*(f+j)='3';i++;j++;break;
case 'G':case 'H':case 'I':case '4':
*(f+j)='4';i++;j++;break;
case 'J':case 'K':case 'L':case '5':
*(f+j)='5';i++;j++;break;
case 'M':case 'N':case 'O':case '6':
*(f+j)='6';i++;j++;break;
case 'P':case 'R':case 'S':case '7':
*(f+j)='7';i++;j++;break;
case 'T':case 'U':case 'V':case '8':
*(f+j)='8';i++;j++;break;
case 'W':case 'X':case 'Y':case '9':
*(f+j)='9';i++;j++;break;
case '-':i++;
}
}
return f;
}
void main()
{
int n=0,i,j,EX_dup=0;
char *c[100],p[20];
int k[100];
scanf("%i",&n);
for(i=0;i<n;i++)
{
scanf("%s",&p);
c[i]=f(p);
for(j=1;j<i;j++)
if(c[j]==c[i])
{
k[j]=k[j]+1;
c[i]="00000000";
EX_dup=1;
}
}
for(n=0;n<100;n++)
if(k[n+1]>0)
{
for(i=0;i<3;i++)
printf("%c",*(c[n]+i));
printf("-");
for(i=3;i<=6;i++)
printf("%c",*(c[n]+i));
printf(" %i",k[n+1]+1);
}
if(EX_dup==0)
printf("No duplicates.");
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator