Permutations

Hello,

Am trying to come with a simple program that can permutate an array.

For example if: string array[] = {"Hello", "World"};

The program would produce every possible combination

Hello
HelloWorld
World
WorldHello

Could anyone help me with this.

Thanks in advance
Think about what you have to do here; think about the number of words that could go into an array and think about what kind of algorithm would work with it.

Now, you know that for this one, you could easily write something like this:
1
2
std::cout << array[1] << std::endl;
[more stuff here]


But, you must conjure an algorithm that goes through an entire list of items.
That may sound strange, but it will soon all be clear.

(Use a notepad or something to mark down your ideas.)
Topic archived. No new replies allowed.