NYOJ 643 text message

Source: Internet
Author: User

SMS time limit: 1000 MS | memory limit: 65535 KB difficulty: 3

Description
It is A commonly used nine-Key English input method interface for mobile phones. If you want to enter the letter 'A', we only need to press the number key 2 at A time, and the key order is marked as 2; if you want to enter the letter 'B, we need to press the number key 2 for two consecutive times, and the key order is marked as 22. Similarly, the letter 'C' needs to press the number key 2 for three consecutive times, and the key order is marked as 222. In this way, we can enter 26 English letters with over 10 keys on the mobile phone. Now, your task is to calculate the key Order entered by the mobile phone in English. Similarly, You need to translate the key order into the corresponding English content. To simplify the problem, we assume that the content only contains uppercase letters and spaces.
Input
Multiple groups of test data
Each group of test data occupies one row in two cases:
(1) text message content (containing only a few spaces and uppercase letters, no more than 1000 characters)
(2) Text Message key Order (containing only a few spaces and numbers, the first of which must be a number, no more than 1000 characters)
Output
For each group of test data:
For text message content, the key order of each letter is output, and the key order of each letter is separated by spaces.
In the key order, output the content it represents
Sample Input
I LOVE YOUHELLO WORLD444 0 555 666 888 33 0 999 666 8844 33 555 555 666 0 9 666 777 555 3
Sample output
444 0 555 666 888 33 0 999 666 8844 33 555 555 666 0 9 666 777 555 3I LOVE YOUHELLO WORLD
Directly simulate!
AC code:
# Include
      
       
# Include
       
        
Int main () {int I, a, B, j, count; char str [1005], ch; while (gets (str )) {if (str [0]> = 'A') & (str [0] <= 'Z') | str [0] = '') {for (I = 0; str [I]! = '\ 0'; I ++) {if (str [I] = '') {printf (" 0 ");} else if (str [I]> = 'A' & str [I] <= 'R') {A = (str [I]-'A ') % 3 + 1; // a indicates the number of buttons B = (str [I]-'A')/3 + 2; // B is the number (j = 1; j <= a; j ++) printf ("% d", B); printf ("");} else if (str [I] ='s ') printf ("7777 "); else if (str [I]> = 'T' & str [I] <= 'y') {a = (str [I]-'T ') % 3 + 1; // a indicates the number of buttons. B = (str [I]-'T')/3 + 8; // B is the number (j = 1; j <= a; j ++) printf ("% d", B); printf ("");} else if (str [I] = 'Z') printf ("9999");} printf ("\ n");} e Lse {for (I = 0; str [I]! = '\ 0'; I ++) {if (str [I] = '') continue; if (str [I] = '0 ') printf (""); if (str [I]> = '2' & str [I] <= '7') {count = 0; a = str [I]-'0'; while (str [I]> = '0' & str [I] <= '7') {count ++; I ++;} ch = (A-2) * 3 + 'A' + (count-1); printf ("% c", ch );} else if (str [I]> = '8' & str [I] <= '9') {count = 0; a = str [I]-'8 '; while (str [I]> = '8' & str [I] <= '9') {count ++; I ++ ;} ch = a * 3 + 'T' + (count-1); printf ("% c", ch) ;}} printf ("\ n ");} memset (str, 0, sizeof (str);} 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.