题目地址


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;
vector<int> chosen;
int n;
void dfs(int x){
    if(x==n+1){
        for(int i=0;i<chosen.size();i++)
            printf("%d ",chosen[i]);
        printf("\n");
        return;
    }
    dfs(x+1);
    chosen.push_back(x);
    dfs(x+1);
    chosen.pop_back();
}
int main(){
    scanf("%d",&n);
    dfs(1);
    return 0;
}