Cod sursa(job #2672786)
| Utilizator | Data | 14 noiembrie 2020 19:27:54 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.6 kb |
#include <fstream>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int comb[20];
void bkt(int n, int k, int nivel, int nr_selectate)
{
if(nivel==n && nr_selectate==k)
{
for(int i=1;i<=k;i++)
fout<<comb[i]<<' ';
fout<<'\n';
}
else if(nr_selectate<=k && nivel<n)
{
comb[nr_selectate+1]=nivel+1;
bkt(n,k,nivel+1,nr_selectate+1);
comb[nr_selectate+1]=0;
bkt(n,k,nivel+1,nr_selectate);
}
}
int main()
{
int n,k;
fin>>n>>k;
bkt(n,k,0,0);
return 0;
}
