Cod sursa(job #1154951)
| Utilizator | Data | 26 martie 2014 15:21:08 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <stdio.h>
using namespace std;
int st[20],n,k;
void afisare()
{
int i;
for (i=1;i<=k;i++)
printf("%d ",st[i]);
printf("\n");
}
void back (int x)
{
int i;
if(x>k)
afisare();
else
for (i=x;i<=n;i++)
{
st[x]=i;
if(st[x]>st[x-1])
back(x+1);
}
}
int main()
{
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%d %d",&n,&k);
back(1);
return 0;
}
