Cod sursa(job #2372431)

Utilizator dey44andIoja Andrei-Iosif dey44and Data 7 martie 2019 09:16:22
Problema Combinari Scor 100
Compilator cpp-64 Status done
Runda pregatire_cls12_oji Marime 0.49 kb
#include <fstream>

using namespace std;

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

int stiva[20], N, K;

void BKT(int nivel)
{
    if(nivel == K + 1)
    {
        for(int i = 1; i <= K; i++)
        out << stiva[i] << " ";
        out << "\n";
    }
    else
    for(int i = stiva[nivel - 1] + 1; i <= N - K + nivel; i++)
    {
        stiva[nivel] = i;
        BKT(nivel + 1);
    }
}

int main()
{
    in >> N >> K;
    BKT(1);
    return 0;
}