combinations of substrings

J

j_depp_99

The requirements for my program is to input a set of substrings into a
vector and produce permutations/ combinations of the substrings. The
resulting strings must be an integer multiple of
the length of the inputted substrings. My program only produces
permutations of each
substring with no replicates. i.e I input 'ab cd ef' into a vector
and
6 being the length of the results. The output I'm supposed to get
should be: " ababab ababcd ababef abcdab" ...etc.
My output is : " abcdef abefcd cdabef cdefab efabcd efcdab " . The
next_combination function is not part of the STL which I thought I
could use. Is there anyway to adjust the next_permutation command to
include repititions?? I though about using nested for loops to print
out each vector element; this works but is there a way using STL
functions.This is the repitition code portion:

<code/>

copy(subString.begin(),subString.end(),ostream_iterator<string>(cout,""));
cout << endl;
while (next_permutation(subString.begin(), subString.end()))
{



copy(subString.begin(),subString.end(),ostream_iterator<string>(cout,""));
cout << endl;
}
</code>

Please, does anyone have a suggestion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top