![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2006
Posts: 2
Rep Power: 0
![]() |
Help with Recursive Function
I need help to write a recursive function that has two inputs, first and second, which both are strings(from ). The function should print all rearrangements of letters in first, followed by second. For example, if first is the string CAT and second is the string MAN, then the function would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN (I think thats all the combinations). The stopping case of the function occurs when the length of first has zero characters. I figured there are two string members that will be needed.
void string::insert(size_type position, size_type number_of_copies, char c); This one to specify number of copies of c have been inserted into the string at the indicated position. Existing characters that used to be at or after the given position have been shifted right one spot. void string::erase(size_type position, size_type n); This one is for n characters have been removed from the string, beginning at the specified position. Can anyone help me get started or even tell me if I'm on the right track? |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
You may have noticed this is not just a C++ problem. It's failing to understand wat needs to be done. How can you find all possible permutations of a word? If you figure it out then tell us, but you probably won't have to as you will probably know what to do.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|