ENCODING
In this program you will be given a letter to encode. The difference here is that different rules are used for different letters and the counting process can cause you to wrap around the alphabet. Using the numerical value of each letter (A=1, B=2, ... Z= 26) the rules are as follows:
If the letter is between the given letters, inclusive:
|
The number of letters to count is given by:
|
A–E
|
Multiply its numerical value by 2
|
F–J
|
Divide its numerical value by 3. Multiply the integer remainder by 5
|
K–O
|
Divide its numerical value by 4. Multiply the integer remainder by 8.
|
P–T
|
Add 10.
|
U- Z
|
Find the largest integer factor of its numerical value less than the value itself. Multiply it by 12.
|
As an example if the letter to encode is a B, the B has a numerical value of 2 and encodes to a 4 and becomes a D, the 4th letter of the alphabet.
The G has a numerical value of 7. It encodes to a 5 and becomes an E.
The numerical value of Z is 26. Its largest factor is 13. You must count 156 (13*12) letters. This has the effect of wrapping around the alphabet 6 complete times and ending at Z. If a numerical value of zero is evaluated print a # symbol.
[Hint: ASCII value of A is 65].
INPUT:
Input consists of an upper case letter.
OUTPUT:
Print the encoded letter it produces.
code:
No comments:
Post a Comment