Cod sursa(job #161223)

Utilizator ViksenVictor-Nicolae Savu Viksen Data 17 martie 2008 19:27:51
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include <iostream>

int main()
{
    int n,k;
    fscanf ( fopen("combinari.in","r") , "%d %d" , &n , &k );
    int V[n+1],i=0,j;
    memset ( V , 0 , sizeof ( V ) );
    freopen ( "combinari.out" , "w" , stdout );
    while ( i+1 )
    {
        if (i==k)
        {
            for (j=0 ; j<k-1 ; j++ ) printf ("%d " , V[j] );
            printf ( "%d\n" , V[j] );i--;
        } else
        if (++V[i]<=n) V[i+1]=V[i++]; else V[i--]=0;
    }
    fclose ( stdout );
    return 0;
}