cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Permutations
Permutations
Nov 12, 2011 at 1:51pm UTC
kato
(6)
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
Nov 12, 2011 at 5:48pm UTC
Ben Duncan
(163)
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.