你的输出样例真的没问题?。。
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int a[100],c[100];
void dfs(int n,int m,int t)
{
if(t==m)
{
for(int i=0;i<m;i++)
cout<<a[i]<<" ";
cout<<endl;
return ;
}
for(int i=1;i<=n;i++)
{
if(c[i]!=0)continue;
c[i]++;
a[t]=i;
dfs(n,m,t+1);
c[i]--;
}
}
int main()
{
int n,m;
while(cin>>n>>m)
{
memset(c,0,sizeof(c));
dfs(n,m,0);
}
return 0;
}
追问应该不会有错吧,不过还是采纳了吧