Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

Write a recursive function with this prototype (using the string type from the new C++ String class): void permute(string first, string second) // Postcondition: The output consists of lines of Strings. Each String // is made by writing some rearrangement of first followed by all // of second. // For example, if first is "CAT" and second is "MAN", then there will // be six lines of output: // CATMAN // ACTMAN // TCAMAN // CTAMAN // ATCMAN // TACMAN Hints: The stopping case occurs when the length of first is zero (in which case the function prints second).

OpenStudy (anonymous):

Some string member functions that will help you for a String s: s[s.length( ) - 1] is a copy of the last character of s. s.length( ) is the length of s. cout << s << endl; will print s. s = c + s; will insert the character c at the front of s. s += c; will append the character c to the end of s. s.erase(0, 1); will remove one character from the front of s. s.erase(s.length( )-1, 1) will remove the last character from s. Can anyone tell me the steps on how to appproach a problem like this? What should I do first and how I double check that my recursive calls are sound?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!