Cod sursa(job #1813710)

Utilizator andreea_zahariaAndreea Zaharia andreea_zaharia Data 23 noiembrie 2016 11:08:19
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include <fstream>

using namespace std;

ifstream fin ("combinari.in");
ofstream fout ("combinari.out");

const int NMAX = 20;

int N, K;
int sol[NMAX];

void print (int n)  {
    for (int i = 1; i <= n; i++) {
        fout << sol[i] << " ";
    }
    fout << '\n';
}

void bkt (int lvl) {
    if (lvl == K + 1) {
        print (K);
    }
    for (int i = sol[lvl - 1] + 1; i <= N; i++) {
        sol[lvl] = i;
        bkt (lvl + 1);
    }
}

int main () {
    fin >> N >> K;
    bkt (1);
    return 0;
}