modified: 6.cpp

This commit is contained in:
2026-08-14 10:03:13 +08:00
parent 1619e9bdde
commit 02af7cc8e5
+5 -4
View File
@@ -1,22 +1,23 @@
// 92
#include <cstdio>
using namespace std;
int c;
bool ch[20];
int n;
void dfs(int now)
{
if (now == n)
if (now > n)
{
for (int i = 1; i <= n; ++i)
{
if (c & (1 << i))
if (ch[i])
printf("%d ", i);
}
puts("");
return;
}
ch[now]=0;
dfs(now + 1);
c &= (1 << now);
ch[now]=1;
dfs(now + 1);
}
int main()