Cod sursa(job #3182783)

Utilizator PsyDuck1914Feraru Rares-Serban PsyDuck1914 Data 9 decembrie 2023 16:15:39
Problema Combinari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f ("combinari.in");
ofstream g ("combinari.out");

vector<int> v;
int k = 3;

void afisare(){
    for(int c : v)
        g << c << ' ';
    g << "\n";
}

void bkt(int poz, int n){
    
    if(poz > n){
        if(v.size() == k){
            afisare();
        }
        return;
    }
    
    v.push_back(poz);
    bkt(poz +1, n);
    v.pop_back();
    bkt(poz +1, n);
    
    
}

int main()
{
    int n;
    f >> n >> k;
    
    bkt(1, n);

    return 0;
}