Pagini recente » Cod sursa (job #1667303) | Cod sursa (job #2509364) | Cod sursa (job #902198) | Cod sursa (job #79052) | Cod sursa (job #2509143)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("combinari.in");
ofstream g("combinari.out");
int N, subm[25], K;
void gen(int element, int lgSubm) {
if (element == N + 1) {
if(lgSubm == K) {
for (int i = 0; i < lgSubm; ++i)
g<<subm[i]<<' ';
g<<"\n";
}
return;
}
subm[lgSubm] = element;
gen(element + 1, lgSubm + 1);
gen(element + 1, lgSubm);
}
int main()
{
f >> N >> K;
int element = 1;
int lgSubm = 0;
gen(element, lgSubm);
return 0;
}