C/C++ how to combine multiple arrays/lists of strings? -


i have 5 lists containing strings: append, word, middle, combo, prepend. (or s0,s1,s2,s3,s4). each list can randomly contain 0 256 strings on program start.

how can output possible combinations?

i tried cascade of for() loops, fails if list in middle contains 0 strings (eg s2).

i assume use std::vector<string> s1,s2,s3,s4,s5;
if ugly code:

int = 1; (auto itr1 = s1.begin(), end1 = s1.end(); itr1 != end1; ++itr1)     (auto itr2 = s2.begin(), end2 = s2.end(); itr2 != end2; ++itr2)         (auto itr3 = s3.begin(), end3 = s3.end(); itr3 != end3; ++itr3)             (auto itr4 = s4.begin(), end4 = s4.end(); itr4 != end4; ++itr4)                 (auto itr5 = s5.begin(), end5 = s5.end(); itr5 != end5; ++itr5)                     std::cout<<"solution "<<i++<< ": "<< *itr1 << " - " << *itr3<< " - " << *itr4<< " - " << *itr5 <<std::endl; 

its not elegant, won't fail when sx.size()==0.

i hope helps!


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -