Cod sursa(job #337556)
| Utilizator | Data | 4 august 2009 00:14:00 | |
|---|---|---|---|
| Problema | Combinari | Scor | 80 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.54 kb |
#include<stdio.h>
const char in[]="combinari.in";
const char out[]="combinari.out";
int n, k, v[11];
void write()
{int i;
for(i=1;i<=k;++i)
printf("%d ",v[i]);
printf("\n");
}
void back(int y)
{int i, ok, j;
if(y==k+1)write();
else for(i=1;i<=n;++i)
{
v[y]=i;
ok=1;
if(y>1)
for(j=1;j<y;++j)
if(v[y] == v[j] || v[y]<v[j])ok=0;
if(ok)back(y+1);
}
}
int main()
{
freopen(in,"r",stdin);
freopen(out,"w",stdout);
scanf("%d %d", &n, &k);
back( 1 );
return 0;
} 