Full array
Dian a recursive algorithm
Every time that a fixed, full array behind looking recursive
How to solve the problem of repeat
We use only the last recurring, check back every time there have been no figures again, there will continue, no operation can be performed recursively, comparing here is O (n) a. If you need faster we can directly use the space flag is visited, which is O (1), but this algorithm to finally factorial level.
Dian two non-recursive algorithm
Generating a sequence of small to large, for example
123 ,132 ,213, 231,312,321
The key issue is to find the next one next to the arrangement, as follows
C ++ STL has been integrated in Algorithm in
next_permutation
If equal, then next slide