40 lines
400 B
C++
40 lines
400 B
C++
#include<bits/stdc++.h>
|
|
using namespace std;
|
|
bool book[10]; //false表示没用过
|
|
int a[10];
|
|
|
|
void print()
|
|
{
|
|
for(int i=1;i<=4;i++)
|
|
{
|
|
cout<<a[i]<<" ";
|
|
}
|
|
cout<<endl;
|
|
}
|
|
|
|
void dfs(int step)
|
|
{
|
|
if(step==5)
|
|
{
|
|
print();
|
|
return ;
|
|
}
|
|
for(int i=1;i<=4;i++)
|
|
{
|
|
if(!book[i])
|
|
{
|
|
book[i]=true;
|
|
a[step]=i;
|
|
dfs(step+1);
|
|
book[i]=false;
|
|
}
|
|
}
|
|
}
|
|
|
|
int main()
|
|
{
|
|
dfs(1);
|
|
|
|
return 0;
|
|
}
|