permutation program

Nov 22, 2011 at 12:24pm
Hi readers, if someone could pass me in the right direction on how to accomplish this please don't reply a search engine lol......

What is needed is to have option to enter string of text and numbers.
then do a permutation on that string x amount of times
display the output!
Nov 22, 2011 at 12:49pm
I don't understand what you mean by permutation in this case. What exactly needs to be done?
Nov 22, 2011 at 1:05pm
if i were to ask a user for input (123456789)
then the program does a permutation on those numbers
outputting the answers
Nov 22, 2011 at 1:23pm
to clarify, if your user inputs say, "123", your program should output:
123, 132, 213, 231, 312, 321

Is this what you mean?
Nov 22, 2011 at 1:31pm
yes i am a novice at C++ hence the reason im asking where to start
Nov 22, 2011 at 1:39pm
The problem is less C++ and more what algorithm to use.

Try this perhaps?
http://www.freewebs.com/permute/soda_submit.html

You might also find helpful:
http://en.wikipedia.org/wiki/Permutation
http://en.wikipedia.org/wiki/Lexicographic_ordering

Otherwise just google "permutation algorithm" and find one you like :)

Likely what you'll need is some kind of nested for loop that swaps the elements around in the string. Just remember to be aware of redundant permutations.
Last edited on Nov 22, 2011 at 1:47pm
Nov 22, 2011 at 2:25pm
thankyou i will ponder on this for now
Topic archived. No new replies allowed.