Convert Number to Letter


Submit solution

Points: 20
Time limit: 2.0s
Memory limit: 64M

Authors:
Problem type

題目說明

<1124檢定考題,1131檢定考題>

設計程式由鍵盤輸入一個數值,根據下面的規則將輸入數值的每一個數字根據對照表置換為字母,
並由螢幕輸出置換後的字串。
規則:
(1) 若出現不在置換表上的數字,輸出「error」。
(2) 若連續兩個數字一樣,輸出「error」。
(3) 若數值的第一位跟最後一位皆為偶數,則在轉換後的字串最後附加上#
(4) 若數值的第一位跟最後一位皆為奇數,則在轉換後的字串最後附加上$

對照表
數字 1 2 3 4 5 6 7 8 9
字母 A B C D E F G H I

輸入

由鍵盤輸入一個數值

輸出

根據上述的規則將輸入數值的每一個數字根據對照表置換為字母後,並由螢幕輸出置換後的字串。

sample input1

4312

sample output1

DCAB#

sample input2

4310

sample output2

error

sample input3

3445

sample output3

error

Comments

There are no comments at the moment.