Cod sursa(job #759811)

Utilizator tony.hegyesAntonius Cezar Hegyes tony.hegyes Data 19 iunie 2012 15:33:35
Problema Combinari Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include <cstdio>
using namespace std;

int n, k, st[19];
void combinari(int);

int main()
{
    //freopen("combinari.in", "r", stdin);
    //freopen("combinari.out", "w", stdout);
    scanf("%d %d", &n, &k);
    combinari(1);

    return 0;
}

void combinari(int schritt)
{
    for (int i = st[schritt - 1] + 1; i <= n; i++)
    {
        st[schritt] = i;
        if (schritt == k)
         {
             for (int j = 1; j <= k; j++)
                printf("%d ", st[j]);
            printf("\n");
         }
        else
            combinari(schritt + 1);
    }
}