Disclaimer: Transfer from http://blog.csdn.net/wencheng2998/article/details/5971194
1#include <iostream>2 using namespacestd;3 intCNT =0;//Total number of cumulative full permutations4 5 6 voidSwapChar*a,Char*b)7 {8 inttemp;9temp = *A;Ten*a = *b; One*b =temp; A } - //k indicates that the elements starting from the following table are K, arranged in the range K to M - voidPermCharList[],intKintm) the { - inti; - if(k = =m) - { + for(i =0; I <= m; i++) - { +cout <<" "<<List[i]; A } atcout << Endl;//Do not output a set of sort, output a line break -cnt++; - } - Else - { - for(i = k; I <= m; i++) in { -Swap (&list[k), &list[i]); toPerm (list, k +1, m); +Swap (&list[k), &list[i]); - } the } * } $ intMain ()Panax Notoginseng { - CharList[] ="12345"; thePerm (List,0,4); +cout <<"the total number of full permutations is:"<<cnt <<Endl; A return 0; the}
[Reprint] Array of the full permutation problem