Description
Enterprises like to use phone numbers that are easy to remember. One way to make phone numbers easy to remember is to write them into words or phrases that are easy to remember. For example, you can call tut-glop when calling the University of Waterloo. Sometimes, only some numbers in the phone number are spelled into words. When you return to the hotel in the evening, you can call 310-gino to order a pizza for Gino's. Another way to make phone numbers easy to remember is to group numbers in a memorable way. Call the "three dozen" numbers of Pizza Hut 3-10-10-10, you can order pizza from them.
The standard telephone number format is a seven-digit decimal number with a connector between the third and fourth digits. The dial number provides a ing from letters to numbers. The ing relationships are as follows:
A, B, and C are mapped to 2.
Map D, E, and F to 3
G, H, and I are mapped to 4
J, k, and l are mapped to 5.
M, N, and O are mapped to 6.
P, R, and s are mapped to 7
T, U, and V are mapped to 8
W, X, and Y are mapped to 9.
Q and Z are not mapped to any number, and do not need to dial connections. They can be added or deleted at will. The standard format of Tut-glop is 888-4567,310-Gino. the standard format of 3-10-10-10 is 310-310.
If the two numbers have the same standard format, they are equivalent (the same dialing)
Your company is compiling a telephone number book for a local company. As part of quality control, you want to check whether two or more companies have the same phone number.
Input
The input format is: the first line is a positive integer that specifies the number (up to 100000) in the phone number book ). The remaining line is a phone number. Each phone number consists of numbers, uppercase letters (except Q and Z), and connectors. Each phone number contains only seven digits or letters.
Output
Generates a line of output for each duplicate number. The output is the standard format of the number followed by a space and the number of duplicates. If multiple duplicate numbers exist, they are output in ascending order according to the number dictionary. If no duplicate numbers exist in the input data, output one line:
No duplicates.
Sample Input
Bytes
Sample output
310-1010 2487-3279 4
888-4567 3
# Include < Stdio. h >
# Include < Stdlib. h >
# Include < String . H >
Char Map [] = " 22233344455566677778889999 " ;
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 ' ];
Continue ;
}
Telnumbers [N] [k] = STR [J];
}
Telnumbers [N] [k] = ' \ 0 ' ;
Return ;
}
Int Main ()
{
Int N, I, j;
Int Noduplicate;
Scanf ( " % D " , & N );
For (I = 0 ; I < N; I ++ ) // Enter the phone number and store it in the array telnumbers.
{
Scanf ( " % S " , STR );
Standardizetel (I ); // Converts the phone number in STR to the standard format and stores it in line I of telnumbers.
}
Qsort (telnumbers, n, 9 , Compare ); // Sort the entered phone numbers
Noduplicate = 1 ;
I = 0 ;
While (I < N) // Search for duplicate phone numbers and output them in advance
{
J = I;
I ++ ;
While (I < N && Strcmp (telnumbers [I], telnumbers [J]) = 0 )
I ++ ;
If (I - J > 1 )
{
Printf ( " % S % d \ n " , Telnumbers [J], I - J );
Noduplicate = 0 ;
}
}
If (Noduplicate)
Printf ( " No duplicates. \ n " );
Scanf ( " % D " , & N );
}