You work for a secret company that writes (-1), (-10) etc etc to represent past characters in
Question:
You work for a secret company that writes (-1), (-10) etc etc to represent past characters in a string. For example, aba = ab(-2), so that (-2) represents a.
Your task is to write a program that takes as input a secret string and then prints the same string with the correct meaning. You may assume that there are no parentheses in the input other than those representing the compressed data.
First sample session with the program:
Text to decompress? hel(-1)o
hello
Second sample session with the program:
Text to decompress? a(-1)rdv(-4)(-4)k
aardvark
Third sample session with the program:
Text to decompress? The cat(-4)in(-3)(-5)(-11)(-11)(-4)(-3)(-11)(-6)
The cat in the hat
Advertising & IMC Principles & Practice
ISBN: 978-0132163644
9th Edition
Authors: Sandra Moriarty, Nancy Mitchell, William Wells