Untitled
unknown
plain_text
2 years ago
475 B
7
Indexable
#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;
}Editor is loading...
Leave a Comment