Cod sursa(job #2596226)
| Utilizator | Data | 9 aprilie 2020 14:34:21 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int n, k;
int combination[20];
void comgen(int i);
int main()
{
fin >> n >> k;
comgen(1);
return 0;
}
void comgen(int i){
if(i == k + 1){
for(int j = 1; j <= k; ++j) fout << combination[j] << " ";
fout << "\n";
return;
}
for(int j = combination[i - 1] + 1; j <= n; ++j){
combination[i] = j;
comgen(i + 1);
}
}
