Last active
January 1, 2016 15:09
-
-
Save KT-Yeh/8162421 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
//English to number | |
int EtoN[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9}; | |
int main() | |
{ | |
int Case,n,i,j,k; | |
int tel[100005]; //用int來存電話 | |
char line[200]; | |
scanf("%d",&Case); | |
while(Case--){ | |
scanf("%d\n",&n); | |
for(i=0;i<n;i++){ | |
scanf("%s",line); | |
tel[i]=0; | |
for(j=0;line[j];j++){ | |
if(line[j]=='-') continue; | |
if(line[j]<='9' && line[j]>='0') | |
tel[i]=tel[i]*10+(line[j]-'0'); | |
else if(line[j]<'Z' && line[j]>='A') | |
tel[i]=tel[i]*10+EtoN[line[j]-'A']; | |
} | |
} | |
sort(tel,tel+n); | |
bool duplicate=1; | |
for(i=0;i<n;){ | |
for(j=i+1;j<n && tel[i]==tel[j];j++) | |
; | |
if(j>i+1){ | |
printf("%.3d-%.4d %d\n",tel[i]/10000,tel[i]%10000,j-i); | |
duplicate=0; | |
} | |
i=j; | |
} | |
if(duplicate) printf("No duplicates.\n"); | |
if (Case) printf("\n"); //注意最後一個Case不能有換行 | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment