The decoding of a natural number n is a string of characters
such that every two digits of n represent a character.
For example, the decoding of n = 6568 is AD
,
because the ASCII code of the character A
is 65 and the ASCII character
of the character D
is 68.
Notice that n has two groups of two digits: 65 and 68.
Another example: the decoding of 65666768 is ABCD
,
since n is composed of 65, 66, 67, and 68.
It is necessary to implement the recursive function
void decodificacio(int)
with the following specification:
PRE:
The input is an integer n such that:
POST:
writes the decoding of n to the output channel cout
.
Observation
Only recursive solutions are accepted.
IMPORTANT: You only need to submit the requested function, and possibly other necessary actions and functions. However, you must keep the type definitions and #include
s.
Input
The input consists of a natural number n ≥ 65 such that n = d1d2d3d4 … dm−1dm m is even and for any pair of digits di di+1 such that i is odd, we have that 65 ≤ di di+1 ≤ 90.
Output
For each integer n, its decoding.
decodificacio(65666768) => "ABCD" decodificacio(6568) => "AD" decodificacio(676665) => "CBA" decodificacio(88) => "X"