Untitled

 avatar
unknown
c_cpp
a year ago
729 B
5
Indexable
#include <bits/stdc++.h>

#define ll long long int
#define ull unsigned long long int
using namespace std;

int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

int n;

vector<int> selected;

void allCombi(int pos)
{
    // base case
    if (pos == n) {
        for (int x: selected) {
            cout << x << ' ';
        }
        cout << '\n';
        return;
    }

    // na niye agabo
    allCombi(pos + 1); // ignore current pos in the set

    // niye agabo
    selected.push_back(arr[pos]);
    allCombi(pos + 1);
    selected.pop_back();
}

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    cin >> n;

    allCombi(0);

    return 0;
}
Editor is loading...
Leave a Comment