Cod sursa(job #713267)

Utilizator mytzuskyMihai Morcov mytzusky Data 14 martie 2012 14:15:10
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.51 kb
#include <iostream>
#include <stdio.h>

using namespace std;

int n,k,sol[20];

void back(int lg, int ls)
{
    if(lg == k+1)
    {
        for(int i=1;i<=k;++i)
            printf("%d ", sol[i]);
        printf("\n");
        return;
    }

    for(int c=ls;c<=n;c++)
    {
        sol[lg] = c;
        back(lg+1, c+1);
    }
}


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

    scanf("%d %d", &n, &k);
    back(1,1);

    return 0;
}