输出反了求调
查看原帖
输出反了求调
1509960
hjluojc楼主2025/7/2 08:17
#include<bits/stdc++.h>
using namespace std;
int n,r,cnt[30];
void dfs(int x,int y){
	if(y>r) return;
	if(y==r){
		for(int i=1;i<=r;i++)
			cout<<setw(3)<<cnt[i];
		cout<<endl;
		return;
	}
	if(x>n) return;
	dfs(x+1,y);
	cnt[y+1]=x;
	dfs(x+1,y+1);
}
int main(){
	cin>>n>>r;
	dfs(1,0);
}


2025/7/2 08:17
加载中...