Pagini recente » Cod sursa (job #3123539) | Cod sursa (job #3285837) | Cod sursa (job #3219165) | Cod sursa (job #3195069) | Cod sursa (job #1813710)
#include <fstream>
using namespace std;
ifstream fin ("combinari.in");
ofstream fout ("combinari.out");
const int NMAX = 20;
int N, K;
int sol[NMAX];
void print (int n) {
for (int i = 1; i <= n; i++) {
fout << sol[i] << " ";
}
fout << '\n';
}
void bkt (int lvl) {
if (lvl == K + 1) {
print (K);
}
for (int i = sol[lvl - 1] + 1; i <= N; i++) {
sol[lvl] = i;
bkt (lvl + 1);
}
}
int main () {
fin >> N >> K;
bkt (1);
return 0;
}