|
|
Subject:
algorithms
Category: Computers > Algorithms Asked by: cyang98-ga List Price: $2.00 |
Posted:
03 Dec 2002 07:58 PST
Expires: 02 Jan 2003 07:58 PST Question ID: 118432 |
A recusive algorithm or sample C or C++ or java program code that can print out all the possible combination order of a character string. For ex: give "ATM", will print out: "ATM", "TAM", "TMA", "MAT", "MTA", "AMT". (n! number orders, n is the nubmer of characters in the string). |
|
Subject:
Re: algorithms
Answered By: xargon-ga on 03 Dec 2002 08:20 PST |
I have two such algorithms for you, both written in C. They both do what you need, although you can easily modify them if need be. Code is from SourceForge.net and is under the GNU General Public License. Permutation Generator This one works, but there could definately be some cleanup done to the code. It is commented a little, but easy to follow. http://sourceforge.net/snippet/detail.php?type=snippet&id=100209 String Permutation Generator This is a more elegant recursive function, with fewer lines of code than the one above. The comments allow for ease of use and modification, although I see no real reason to need to modify this snippet. http://sourceforge.net/snippet/detail.php?type=snippet&id=100376 I hope that helps with your problem! Xargon-ga |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |