Cod sursa(job #750036)

Utilizator Theorytheo .c Theory Data 20 mai 2012 10:52:20
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#include<fstream>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int N, K;
bool uz[20];
int v[20];
int i;
void read()
{
    fin >> N >> K;
}
void display()
{
    for(int i = 1; i <= K; i++)
        fout << v[i] <<" " ;
    fout <<'\n';
}
void back(int k)
{
    if(k > K)
        display();

    else
        for(int element = v[k - 1] + 1; element <= N; element++)
            {
                v[k] = element;
                back(k + 1);
            }

}
int main()
{
    read();
    back(1);
    fin.close();
    return 0;
}