Question: Write a C + + program for a string decoder. 1 ) The program prompts the user to enter a string, for example: p (
Write a C program for a string decoder. The program prompts the user to enter a string, for example: pabdfeghkq There are nested words enclosed within parentheses. The decoder's job is to extract and reverse each nested word, removing the parentheses in the process. If a nested structure has other nested structures within it it should be decoded from the inner structure first and then to outer one. Write a recursive function decodeLanguage that returns the decoded strings and print it out in the main function. Here are some detailed examples: pabdfeghkq removing the inner most parentheses, we get pabefdghkq; pabefdghkq removing the outer parentheses pkhgdfebaq, which is the final output abcde will output adcbe abcde will output abcde Hints: Find the innermost parentheses first and reverse the string inside them. Recursively decode and replace until no parentheses remain in the string.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
