Cod sursa(job #1128336)
| Utilizator | Data | 27 februarie 2014 16:35:16 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.59 kb |
#include <cstdio>
#define NMAX 27
using namespace std;
int v[NMAX], Ap[NMAX];
int n, m;
void back(int k){
if(k == m + 1){
for(int i = 1; i <= m; ++i)
printf("%d ", v[i]);
printf("\n");
}
else
for(int i = v[k - 1] + 1; i <= n; ++i){
v[k] = i;
if(k <= n && Ap[i] == 0){
Ap[i] = 1;
back(k + 1);
Ap[i] = 0;
}
}
}
int main(){
freopen("combinari.in", "r", stdin);
freopen("combinari.out", "w", stdout);
scanf("%d %d", &n, &m);
back(1);
return 0;
}
