提交时间:2023-08-25 09:47:39
运行 ID: 100231
#include <bits/stdc++.h> using namespace std; int num[25]; void dfs(int n, int m, int curM, int d) { if (curM == m+1) { for (int i = 1; i <= m; i++) { cout << num[i]; } cout << endl; return; } for (int i = d+1; i <= n; i++) { num[curM] = i; dfs(n, m, curM+1, i); } } int main() { int n, m; cin >> n >> m; dfs(n, m, 1, 0); return 0; }