Pagini recente » Statistici Crisan Amalia Maria (AmaliaCrisan) | Profil pincess | Profil 1mihaialexandru | Statistici Mihai Smolenski (mihaismolenski) | Cod sursa (job #1844362)
#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 19;
int n, k, st[MAXN];
void combinari(int q = 1) {
int i = 1;
if (q >= 2) {
i = st[q - 1] + 1;
}
for (; i <= n; ++i) {
st[q] = i;
if (q == k) {
for (int i = 1; i <= k; ++i) {
cout << st[i] << ' ';
}
cout << '\n';
} else {
combinari(q + 1);
}
}
}
int main(int argc, const char * argv[]) {
freopen("combinari.in", "r", stdin);
freopen("combinari.out", "w", stdout);
cin >> n >> k;
combinari();
return 0;
}