题目链接
题解
#include<bits/stdc++.h>
using namespace std;
int n, r;
int ans[25];
int vis[25];
void dfs(int dep){
if(dep==r+1){
for(int i=1; i<dep; i++)cout<< setw(3)<<ans[i];
cout<<endl;
}
for(int i=ans[dep-1]+1; i<=n; i++){
if(!vis[i]){
ans[dep]=i;
vis[i]=1;
dfs(dep+1);
vis[i]=0;
}
}
}
int main()
{
cin>>n>>r;
dfs(1);
return 0;
}
标签:输出,组合,25,int,dfs,dep,P1157
From: https://www.cnblogs.com/tflsnoi/p/17232543.html