Poj1002 phone number

Source: Internet
Author: User

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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.