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