#include <iostream>#include <algorithm>#include <string>using namespace std;void DFS(string a,int i,int j){ if(i>=j) cout<<a<<endl; else for(int k=i;k<j;k++) { swap(a[i],a[k]); DFS(a,i+1,j); swap(a[i],a[k]); }}
int main(){ string a = "12345";DFS(a,0,5);
return 0;}
转载于:https://www.cnblogs.com/ruoh3kou/p/7804909.html
相关资源:如何通过python实现全排列