Search:
Forum
General C++ Programming
permutation program
permutation program
Nov 22, 2011 at 12:24pm UTC
amberleef
(22)
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 UTC
Mooncabbage
(8)
I don't understand what you mean by permutation in this case. What exactly needs to be done?
Nov 22, 2011 at 1:05pm UTC
amberleef
(22)
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 UTC
Mooncabbage
(8)
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 UTC
amberleef
(22)
yes i am a novice at C++ hence the reason im asking where to start
Nov 22, 2011 at 1:39pm UTC
Mooncabbage
(8)
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 UTC
Nov 22, 2011 at 2:25pm UTC
amberleef
(22)
thankyou i will ponder on this for now
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs