Cod sursa(job #2574210)

Utilizator victorzarzuZarzu Victor victorzarzu Data 5 martie 2020 20:56:52
Problema Combinari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.46 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("combinari.in");
ofstream g("combinari.out");
int n, k;
int s[20];

void back(int l)
{
    if(l == k)
    {
        for(int i = 1;i <= k;++i)
            g<<s[i]<<" ";
        g<<'\n';
    }
    else
    {
        for(int i = s[l] + 1;i <= n;++i)
        {
            s[l + 1] = i;
            back(l + 1);
        }
    }
}

int main()
{
    f>>n>>k;
    back(0);
    return 0;
}