哪里错了啊 急急急

P1157 组合的输出

# [个人博客主页](https://www.ricemoon.cn/) ```cpp #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; typedef pair<int, int> PII; int n, r; int path[30]; bool st[30]; void dfs(int u, int num) { if (u == r + 1) { for (int i = 1; i <= r; i ++) cout << setw(3) << path[i]; cout << endl; } for (int i = 1; i <= n; i ++) { if (!st[i] and i > num) { st[i] = true; path[u] = i; dfs(u + 1, path[u]); st[i] = false; path[u] = 0; } } } int main() { cin >> n >> r; dfs(1, 0); return 0; } ```
by Roger_Spencer @ 2023-03-05 20:53:48


|