Cod sursa(job #1712528)
Utilizator | Nisioi Ciprian CipiNis | Data | 2 iunie 2016 23:46:23 |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.58 kb |
#include <fstream>
#define MAX 19
using namespace std;
ifstream in_f("combinari.in");
ofstream out_f("combinari.out");
int n, k, v[MAX];
void Write(int x)
{
for(int i = 1; i <= x; ++i)
out_f << v[i] << " ";
out_f << "\n";
}
bool Sol(int x)
{
return x == k ? 1 : 0;
}
void BK(int x)
{
int i;
for(i = v[x - 1] + 1; i <= n; ++i){
v[x] = i;
if(Sol(x))
Write(x);
else BK(x + 1);
}
}
int main()
{
in_f >> n >> k;
BK(1);
in_f.close();
out_f.close();
return 0;
}