Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 12th, 2006, 3:55 PM   #1
Rawr101
Newbie
 
Join Date: Apr 2006
Posts: 2
Rep Power: 0 Rawr101 is on a distinguished road
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?
Rawr101 is offline   Reply With Quote
Old Apr 12th, 2006, 5:14 PM   #2
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC