Question: In C + + Given two functions: int extractInt ( const char src [ ] , int& index,int& depth ) , which extracts the first
In C
Given two functions:
int extractIntconst char src int& index,int& depth which extracts the first few digits from array src until ecountering a and converting into integers, ie char srcab would only return in integer form, and is safe to assume the first characters until the first are all digits.
Another function void repeatStringchar str int repeattimes, char repeatedstr would repeat strrepeattimes times and save into repeatedstr ie for str "abd", repeattimes repeatedstr would be "abdabdabd".
Use these two defined functions to constuct another function:
void recursiveDecodeconst char src int& index, char decoded
where src would be the input string, and decoded would be the decoded string, demonstrated below:
srcaba decoded ababa
srcababfb decoded ababfbfabfbfabfbfb
In other words, the strings in the brackets would be repeated multiple times determined by the integers before it where the integers could be many digits.
It can be assumed that would only have integers before it iea while aa would be invalid and would not appear in the inputs. Nested brackets however, are possible.
Write the final function in terms of the functions defined, with no added parameters, only usable libraries are and
And DO NOT use any while or for loops for the function, only recursion is allowed
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
