Cod sursa(job #1932632)
| Utilizator | Data | 19 martie 2017 22:27:03 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include <bits/stdc++.h>
#define maxN 20
FILE *fin = freopen("combinari.in", "r", stdin);
FILE *fout = freopen("combinari.out", "w", stdout);
using namespace std;
int N, K, c[maxN];
void write(){
for(int i = 1; i <= K; ++ i)
printf("%d ", c[i]);
printf("\n");
}
void comb(int k){
if(k > K)
write();
else for(int i = c[k - 1] + 1; i <= N; ++ i){
c[k] = i;
comb(k + 1);
}
}
int main(){
scanf("%d %d", &N, &K);
comb(1);
return 0;
}
