Cod sursa(job #1323400)

Utilizator gabrielvGabriel Vanca gabrielv Data 20 ianuarie 2015 23:15:45
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include <cstdio>

using namespace std;

int N,K;

int v[25];

void Back(int step, int val)
{
    v[step] = val;

    if(step == K)
    {
        for(step=1;step<=K;step++)
            printf("%d ",v[step]);
        printf("\n");
        return;
    }

    for(int i=v[step]+1;i<=N;i++)
        Back(step+1,i);
}

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

    scanf("%d%d",&N,&K);

    Back(0,0);

    return 0;
}