Cod sursa(job #1915078)
| Utilizator | Data | 8 martie 2017 19:35:59 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.61 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int st[20],n,k,top,viz[20];
void Afisare()
{
int i;
for(i=1; i<=k; i++)
fout<<st[i]<<" ";
fout<<"\n";
}
void Back(int top)
{
int i;
if(top==k+1)
Afisare();
else for(i=1+st[top-1]; i<=n; i++)
if(!viz[i])
{
viz[i]=1;
st[top]=i;
Back(top+1);
viz[i]=0;
}
}
int main()
{
fin>>n>>k;
Back(1);
fin.close();
fout.close();
return 0;
}
