Cod sursa(job #2296612)

Utilizator SochuDarabaneanu Liviu Eugen Sochu Data 4 decembrie 2018 20:41:35
Problema Combinari Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.41 kb
#include <iostream>
using namespace std;
int n,m,a[50],k,q;
void afisare_sol()
{
    for(int i=1; i<=k; i++)
        cout<<a[i]<<" ";
    cout<<endl;
}
void comb(int q)
{
    int i;
    if(q==k+1)
        afisare_sol();
    else
        for(i=a[q-1]+1; i<=n-k+q; i++)
        {
            a[q]=i;
            comb(q+1);
        }
}
int  main()
{
    cin>>n>>k;
    a[0]=0;
    comb(1);
}