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.
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.