Cod sursa(job #303528)
Utilizator | Data | 9 aprilie 2009 22:23:48 | |
---|---|---|---|
Problema | Combinari | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
# include <fstream>
using namespace std;
int n, k, v[20], x[20];
ofstream fout ("combinari.out");
void afis ()
{
int i;
for (i=1;i<=k;i++)
fout<<x[i]<<" ";
fout<<endl;
}
void comb (int i)
{
int j;
if (i==k+1)
afis ();
else
for (j=i;j<=i+n-k;j++)
if (v[j]==0)
{
x[i]=j;
v[j]=1;
comb (i+1);
v[j]=0;
}
}
int main ()
{
ifstream fin ("combinari.in");
fin>>n>>k;
comb (1);
return 0;
}