There should be many practices for this question. Considering that the maximum phone number here is 999-9999, I chose a mind-saving method and opened an array of 10000000 ......... so the rest of the work is to convert the input string to an integer. Pay attention to the correspondence between English letters and numbers, and then a simple atoi.
# Include <stdio. h> # include <string. h> int count [10000000]; int alpha_to_digit [] = {, 9, 9, 0}; int main (void) {int N; char STR [300]; int digit; char C; int I; memset (count, 0, sizeof (count )); scanf ("% d", & N); While (n --) {scanf ("% s", STR); I = 0; digit = 0; while (C = STR [I ++])! = '\ 0') {If (C ='-'| C = 'q' | C = 'Z') {continue ;} if (C> = 'A' & C <= 'Z') {digit = digit * 10 + alpha_to_digit [(INT) (C-'A')];} else {digit = digit * 10 + (INT) (C-'0') ;}} count [digit] ++;} int find = 0; for (I = 0; I <10000000; I ++) {If (count [I]> 1) {find = 1; printf ("% 03d-% 04d % d \ n ", i/10000, I % 10000, Count [I]) ;}} if (! Find) {printf ("no duplicates. \ n");} return 0 ;}