Cod sursa(job #173554)
Utilizator | Data | 7 aprilie 2008 20:41:40 | |
---|---|---|---|
Problema | Combinari | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.52 kb |
#include<stdio.h>
long s[21],n,c,k;
void back(long int c)
{long int i,j;
int ok;
if(c==k)
{for(i=1;i<=k;i++)
printf("%ld",s[i]);
printf("\n");
}
else
{for(i=1;i<=n;i++)
{ok=1;
for(j=1;j<=c;j++)
if(s[j]==i)
{ok=0;
break;
}
if(ok)
{s[c+1]=i;
back(c+1);
}
}
}
}
int main()
{
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%ld %ld",&n,&k);
back(0);
return 0;
}