Cod sursa(job #158304)
Utilizator | Data | 13 martie 2008 16:23:41 | |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <stdio.h>
long n,k;
long st[30];
void back(int x)
{
long i;
if (x==k+1)
{
for (i=1; i<=k; i++)
printf("%ld ",st[i]);
printf("\n");
return;
}
for (i=st[x-1]+1; i<=n; i++)
{
st[x]=i;
back(x+1);
}
}
int main()
{
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%ld %ld",&n,&k);
back(1);
fclose(stdin);
fclose(stdout);
return 0;
}