Cod sursa(job #3212557)

Utilizator MerlinTheWizardMelvin Abibula MerlinTheWizard Data 11 martie 2024 21:35:47
Problema Submultimi Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.52 kb
#include<bits/stdc++.h>

using namespace std;

vector<int> v;
int n;

void afisare()
{
    for(int i = 1; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}

void bkt()
{
    if(v.size() != 1)
        afisare();
    for(int i = v.back() + 1; i <= n; i++)
    {
        v.push_back(i);
        bkt();
        v.pop_back();
    }
}

int main()
{
    freopen("submultimi.in", "r", stdin);
    freopen("submultimi.out", "w", stdout);

    cin >> n;

    v.push_back(0);
    bkt();
}