Cod sursa(job #964957)
Utilizator | Iordan Vlad Vladinho97 | Data | 22 iunie 2013 20:02:36 |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.54 kb |
#include <cstdio>
using namespace std;
int st[20],n,k;
void afisare()
{
int i;
for(i=1;i<=k-1;i++)
printf("%d ",st[i]);
printf("%d\n",st[k]);
}
void back(int nivel)
{
int i;
if(nivel==k+1)
afisare();
else
for(i=st[nivel-1]+1;i<=n-k+nivel;i++)
{
st[nivel]=i;
back(nivel+1);
}
}
int main()
{
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%d%d",&n,&k);
st[0]=0;
back(1);
return 0;
}