Cod sursa(job #1474216)
| Utilizator | Data | 21 august 2015 15:37:35 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
#include <iostream>
#define fin "combinari.in"
#define fou "combinari.out"
using namespace std;
ifstream t1(fin);
ofstream t2(fou);
int n,k;
int sol[20];
void bkt(int poz)
{
int i;
if(poz==k+1) { for(i=1;i<=k;i++) t2<<sol[i]<<' '; t2<<'\n'; }
else
{
for(i=sol[poz-1]+1;i<=n;i++)
{
sol[poz]=i;
bkt(poz+1);
}
}
}
int main()
{
t1>>n>>k;
bkt(1);
t1.close();
t2.close();
return 0;
}
