全排列:当n==m时,称为全排列;
#include<iostream> using namespace std; void permutation(char *str, int k, int m) { if (k == m) { for (int i = 0; i <= m; i++) { cout << str[i]; } cout << endl; } else { for (int j = k; j <= m; j++) { swap(str[j], str[k]); permutation(str, k + 1, m); swap(str[j], str[k]); } } }
参考来源:http://blog.csdn.net/xiazdong/article/details/7986015
原文:http://www.cnblogs.com/shutter/p/4733303.html