From 02af7cc8e592327059b43f8c860eea46bd620b81 Mon Sep 17 00:00:00 2001 From: hanyixuanten Date: Fri, 14 Aug 2026 10:03:13 +0800 Subject: [PATCH] modified: 6.cpp --- 6.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/6.cpp b/6.cpp index 3922abb..9611f4b 100644 --- a/6.cpp +++ b/6.cpp @@ -1,22 +1,23 @@ // 92 #include 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()