Solution

cookiebus 2022-11-12 15:03:24 24 返回题目

#include <bits/stdc++.h>
using namespace std;
int a[20], n, r;
void dfs(int x) {
	if (x > r) {
		for (int i = 1; i <= r; ++i)
			cout << " " << a[i];
		cout << endl;
		return ;
	}
	
	for (int i = a[x - 1] + 1; i <= n; ++i) {
		a[x] = i;
		dfs(x + 1);
	}
}
int main() {
	
	cin >> n >> r;
	
	dfs(1);
	return 0;
}
{{ vote && vote.total.up }}