抄了全排列
#include<bits/stdc++.h>
using namespace std;
int n,m,a[21];
bool b[21];
void dfs(int step){
if(step>m){
for(int i=1;i<=m;i++) cout<<a[i]<<" ";
cout<<endl;
return;
}
for(int i=1;i<=n;i++){
if(b[i]==0){
b[i]=1;
a[step+1]=i;
dfs(step+1);
b[i]=0;
}
}
}
int main(){
scanf("%d%d",&n,&m);
dfs(0);
return 0;
}