Cod sursa(job #964955)
| Utilizator | Data | 22 iunie 2013 20:00:58 | |
|---|---|---|---|
| Problema | Combinari | Scor | 0 |
| 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];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]=1;
back(1);
return 0;
}
