标签:
关于全排列:
# include <iostream>
# include <cstdio>
using namespace std;
void perm(int list[], int k, int m)
{
int i;
if(k > m)
{
for(i = 0; i <= m; i++)
printf("%d ", list[i]);
printf("\n");
}
else
{
for(i = k; i <= m; i++)
{
swap(list[k], list[i]);
perm(list, k + 1, m);
swap(list[k], list[i]);
}
}
}
int main()
{
int list[] = {1, 2, 3, 4};
perm(list, 0, 3);
return 0;
}
标签:
原文地址:http://www.cnblogs.com/lyf-acm/p/5469903.html