The students notice several sketchy papers on Mr. Venom's desk, each containing
Why do they keep making me use these stupid codes?! Note to self: Start at the first integer
on the paper, then skip ahead positions (or behind, if is negative). The integer you land on decodes to an uppercase alphabetic character . Move to the next integer after the one you just decoded and skip ahead (or behind if is negative) spaces from there. Repeat until you (at any point) move to a , at which point the program should terminate immediately. Hey, at least you will always skip to a position that's actually on the page, and there will always be a number after that. Who even designed this stupid code?
Input Specification
The first line of input consists of integer
Output Specification
The output is the decoded message in uppercase.
Sample Input 1
9
2
22
5
-2
10
12
0
9
-3
Sample Output 1
EVIL
Explanation of Sample Output 1
You first skip forwards by E
. The next number after V
. The next integer is a I
. You then skip backward by L
. The next number is
Sample Input 2
20
9
1
4
12
4
0
3
1
5
11
-10
16
5
16
-3
14
-9
5
-14
0
Sample Output 2
KIDNAPPED
Comments
RTE ? can someone tell me why my program raises the bad_alloc error
The message terminates when it lands on a zero. There is one case where this happens that you did not consider.