Cod sursa(job #2416277)
| Utilizator | Data | 27 aprilie 2019 11:57:39 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("combinari.in");
ofstream out("combinari.out");
int n, k;
int c[20];
bool used[20];
void write()
{
for(int i = 1; i <= k; i++)
out << c[i] << ' ';
out << '\n';
}
void gen(int pos)
{
if(k < pos)
write();
else
{
for(int i = c[pos - 1] + 1; i <= n; i++)
{
c[pos] = i;
gen(pos + 1);
}
}
}
int main()
{
in >> n >> k;
gen(1);
in.close();
out.close();
return 0;
}
