Cod sursa(job #1202674)

Utilizator EhtRalpmetFMI Ardei Claudiu-Alexandru EhtRalpmet Data 29 iunie 2014 00:08:40
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
//#include <iostream>
#include<fstream>
#include<string>
#include<queue>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
ifstream cin("combinari.in");
ofstream cout("combinari.out");

int i,n,k,v[100];

void afisare(){
    for(i=1;i<=k;i++){
        cout<<v[i]<<' ';
    }
    cout<<'\n';
}

void bck(int nivel){
    if(nivel==k){
        afisare();
        v[k]=0;
        return;
    }

    for(int j=v[nivel]+1;j<=n-k+nivel+1;j++){
        v[nivel+1]=j;
        bck(nivel+1);
    }
}

int main()
{
    cin>>n>>k;
    bck(0);

    return 0;
}