#include<iostream>
using namespace std;
template<class Type>
inline void Swap(Type &a,Type &b){
Type temp = a;
a = b;
b = temp;
}
template<class Type>
void Perm(Type list[],int k,int m){
if(k == m)
{
for(int i = 0;i<=m;i++)
cout<<list[i];
cout<<endl;
}
else
for(int i = k;i <= m;i++){
Swap(list[k],list[i]);
Perm(list,k+1,m);
Swap(list[k],list[i]);
}
}
void main(){
int L[3] = {1,2,3};
Perm(L,0,2);
}
递归分治解决全排列问题
最新推荐文章于 2020-06-07 19:00:20 发布