Cod sursa(job #3350817)
| Utilizator | Data | 13 aprilie 2026 16:32:19 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int n,k;
int p[19];
void afisare(int a)
{
for (int i = 1;i <= a;i++)
{
fout << p[i] << " ";
}
fout << "\n";
}
void back(int x)
{
for (int i=p[x-1]+1;i <= n;i++)
{
p[x] = i;
if (k == x)
{
afisare(k);
}
else
{
back(x + 1);
}
}
}
int main()
{
fin >> n >> k;
p[0] = 0;
back(1);
}