Cod sursa(job #359357)
Utilizator | Data | 26 octombrie 2009 19:04:56 | |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.55 kb |
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int sol[20],n,p;
void back(int k)
{
if (k==p+1)
{for (int i=1;i<=p;i++)
printf("%d ", sol[i]);
printf("\n");}
else
{sol[k]=0;
if (k>1) sol[k]=sol[k-1];
else sol[k]=0;
while (sol[k]<n)
{sol[k]++;
back(k+1);}}}
int main()
{
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%d%d",&n,&p);
back(1);
return 0;}