Cod sursa(job #1589130)
| Utilizator | Data | 3 februarie 2016 19:50:44 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <cstdio>
using namespace std;
int n,k,st[20],viz;
void Afisare()
{int i;
for(i=1;i<=k;i++)
printf("%d ",st[i]);
printf("\n");
}
void Back(int top)
{int i;
if(top==k+1)Afisare();
else {for(i=st[top-1]+1;i<=n;i++)
{st[top]=i;
Back(top+1);
}
}
}
int main()
{freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%d%d",&n,&k);
Back(1);
}
