The problem has two parts:
1. Reverse a string
I wrote a function:
std::string reverse( const std::string& s )
Inside the function I just used the std::reverse() algorithm to reverse a copy of the argument, which I then return.
Of course, you can do it yourself just as easily: start indexing from both ends of the string, swap, increment/decrement the indices, repeat until they cross.
2. Zip two strings together
Consider the unequal strings that you want to interleave:
Sue
yggeP
While there are characters remaining in both strings, get the next character from each string and add them to the result string.
Once one (or both) of the strings is out of characters, simply append the characters from the remaining string to the result string.
Sue Sue Sue Sue
yggeP yggeP yggeP yggeP
↑ ↑ ↑ ↑
→Sy →Syug →Syugeg →SyugegeP
|
Notice how we just use the next two letters.
In the final step, we ran out of letters for one of the names, so we just tacked the remaining letters in the other name onto the end.
You can do this in about fifteen lines of code.
Good luck!