Cod sursa(job #2705650)
Utilizator | Data | 13 februarie 2021 09:22:23 | |
---|---|---|---|
Problema | Submultimi | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
using namespace std;
ifstream f("combinari.in");
ofstream g("combinari.out");
int n, k, sol[20];
void generare(int q)
{
if (q == k+1)
{
for (int i=1; i<=k; i++)
g << sol[i] << ' ';
g << '\n';
}
else{
for (int i=sol[q-1] + 1; i<=n; i++)
{
sol[q] = i;
generare(q+1);
}
}
}
int main()
{
f >> n >> k;
generare(1);
}