Cod sursa(job #303531)
Utilizator | Data | 9 aprilie 2009 22:39:31 | |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
# include <stdio.h>
using namespace std;
int n, k, v[20], x[20];
FILE*f=freopen ("combinari.out", "w", stdout);
void afis ()
{
int i;
for (i=1;i<=k;i++)
printf ("%d ", x[i]);
printf ("\n");
}
void comb (int i)
{
int j;
if (i==k+1)
afis ();
else
for (j=x[i-1]+1;j<=n;j++)
if (v[j]==0)
{
x[i]=j;
v[j]=1;
comb (i+1);
v[j]=0;
}
}
int main ()
{
freopen ("combinari.in", "r", stdin);
scanf ("%d %d", &n, &k);
comb (1);
return 0;
}