samurai
2006-05-06 23:53:00 UTC
determine all of the n elements' arrangements.
for example,if there is 1 element,say, A1,there is only one
permutation, namely,{A1};
if there are 2 elements,say,A1 and A2,there are two
arrangements,namely, {A1,A2},{A2,A1};
3 elements, A1,A2 and A3, six permutations
exist,{A1,A2,A3},{A2,A1,A3},{A3,A1,A2},{A3,A2,A1},{A1,A3,A2},{A2,A3,A1};
.......
so if there are n elements, how can we use recursive algorithm to determine all of these permutations?
of course We know that there are n! permutations of n elements,but i
just want to make a program to print what does every permutation look
like,like
this,{A1,A2,A3},{A2,A1,A3},{A3,A1,A2},{A3,A2,A1},{A1,A3,A2},{A2,A3,A1}.
can anyone give me some tips?