Pagini recente » Cod sursa (job #534485) | Cod sursa (job #2868064) | Cod sursa (job #1211148) | Rating iustin (iustin2002) | Cod sursa (job #362808)
Cod sursa(job #362808)
#include <stdio.h>
#define N 18
int st[N + 1], n, k;
void back(int nivel)
{
if(nivel == k + 1)
{
for(int i = 1; i <= k; ++i) printf("%d ", st[i]);
printf("\n");
}
else
{
for(st[nivel] = st[nivel - 1] + 1; st[nivel] <= n; ++st[nivel])
{
back(nivel + 1);
}
}
}
int main()
{
freopen("combinari.in", "r", stdin);
freopen("combinari.out", "w", stdout);
scanf("%d%d", &n, &k);
fclose(stdin);
back(1);
fclose(stdout);
return 0;
}