Pagini recente » Cod sursa (job #1577439) | Istoria paginii runda/cerculdeinfo-lectia14-cautare_binara/clasament | Cod sursa (job #211916) | Cod sursa (job #2098251) | Cod sursa (job #2566124)
#include <fstream>
#include <iostream>
#include <stack>
using namespace std;
const int N = 20;
int n, k, st[N];
ofstream fout ("combinari.out");
void Write (int x)
{
for (int i = 1; i <= x; i++)
fout << st[i] << " ";
fout << "\n";
}
void Back (int top)
{
if (top > k)
Write (top - 1);
else for (int i = st[top - 1] + 1; i <= n - k + top; i++)
{
st[top] = i;
Back(top + 1);
}
}
void Read ()
{
ifstream fin ("combinari.in");
fin >> n >> k;
Back(1);
fout.close();
fin.close();
}
int main()
{
Read();
return 0;
}