dfs实现全排列
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int bok[100];
int path[100];
void dfs(int step)
{
if(step==4)
{
for(int i=1;i<=step-1;i++) cout<<path[i];
cout<<endl;
return ;
}
for(int i=1;i<=3;i++)
{
if(!bok[i])
{
path[step] = i;
bok[i] = 1;
dfs(step+1);
bok[i] = 0;
}
}
}
int main()
{
int a[]={0,1,2,3,4};
dfs(1);
}