Cod sursa(job #1374681)
| Utilizator | Data | 5 martie 2015 10:27:09 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.64 kb |
#include <fstream>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int n,m,sol[20];
bool uz[20];
void afiseaza()
{
int i;
for(i=1;i<=m;i++)
fout<<sol[i]<<' ';
fout<<'\n';
}
void combinari(int k)
{
int cand;
if(k==m+1)
afiseaza();
else
for(cand=sol[k-1]+1;cand<=n;cand++)
{
if(!uz[cand])
{
sol[k]=cand; uz[cand]=1;
combinari(k+1);
sol[k]=0; uz[cand]=0;
}
}
}
int main()
{
fin>>n>>m;
combinari(1);
return 0;
}
