new file: 6.cpp
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
// 92
|
||||||
|
#include <cstdio>
|
||||||
|
using namespace std;
|
||||||
|
int c;
|
||||||
|
int n;
|
||||||
|
void dfs(int now)
|
||||||
|
{
|
||||||
|
if (now == n)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= n; ++i)
|
||||||
|
{
|
||||||
|
if (c & (1 << i))
|
||||||
|
printf("%d ", i);
|
||||||
|
}
|
||||||
|
puts("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dfs(now + 1);
|
||||||
|
c &= (1 << now);
|
||||||
|
dfs(now + 1);
|
||||||
|
}
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
scanf("%d", &n);
|
||||||
|
dfs(1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user