Untitled

mail@pastecode.io avatar
unknown
plain_text
22 days ago
475 B
1
Indexable
Never
#include <bits/stdc++.h>

using namespace std;

const int N = 100;

int n;
int a[N];
vector<int> ans;
void rec(int pos) {
    if (pos == n) {
        for (auto it : ans) {
            cout << it << ' ';
        }
        cout << '\n';
        return;
    }
    ans.push_back(a[pos]);
    rec(pos + 1);

    ans.pop_back();
    rec(pos + 1);
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    rec(0);
}

int main() {

    solve();
    return 0;
}
Leave a Comment