//poj:2974 #include<stdio.h> #include<string.h> #include<stdlib.h> char map[]="2223334445556667*77888999*"; char str[80],telNumbers[100000][9]; int compare(const void *elem1,const void *elem2) { return (strcmp((char *)elem1,(char *)elem2)); } void standardizeTel(int n) { int j,k; j=k=-1; while(k<8) { j++; if(str[j]=='-')// continue; k++;// if(k==3) { telNumbers[n][k]='-'; k++;// } if(str[j]>='A' && str[j]<='Z')//>= <= { telNumbers[n][k]=map[str[j]-'A'];//map[] continue; } telNumbers[n][k]=str[j]; } telNumbers[n][k]=' '; } int main() { int n,i,j; bool noduplicate; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s",str); standardizeTel(i); } qsort(telNumbers,n,9,compare); noduplicate=true; i=0;// while(i<n) { j=i; i++; while(i<n && strcmp(telNumbers[j],telNumbers[i])==0) i++;//while if(i-j>1) { printf("%s %d ",telNumbers[j],i-j); noduplicate=false; } } if(noduplicate) printf("No duplicate "); return 0; }