Hi all,
I am new to
JAVA.
I wanna write a Permutation code.
For example, I have [1,2,3]. I want to print 123,132,213,231,312,321
Below is my code:
However, it will print 123,132,312,321,123,132.
Actually, I use the algorithm from "Data Structures with C++ Using STL" by WIlliam Ford and WIlliam Topp. In this book, there is a section "Listing Permutations" described this algorithm.
So, why is it wrong?
Thanks.
[Update: Added code tags (Read UseCodeTags) ]