Pagini recente » Istoria paginii utilizator/suranimaria_ | Profil Alexandra | Cod sursa (job #2008319) | Statistici Toma AlimoS (TomaAlimos) | Cod sursa (job #2008317)
#include<fstream>
#include<iostream>
using namespace std;
ifstream fin ("combinari.in");
ofstream fout ("combinari.out");
int n, k, st[20];
void Afisare()
{
int i;
for (i=1; i<=k; i++)
fout << st[i] << " ";
fout << "\n";
}
void Back(int top)
{
int i;
if (top == k+1) Afisare();
else
for (i=st[top-1]+1; i<=n-k+top; i++)
{
st[top] = i;
Back(top+1);
}
}
int main ()
{
fin >> n >> k;
Back(1);
return 0;
}