Pagini recente » Borderou de evaluare (job #573877) | Borderou de evaluare (job #573885) | Cod sursa (job #1254279)
#include <iostream>
#include <fstream>
using namespace std;
int n,k;
int st[20];
ifstream fin("combinari.in");
ofstream fout("combinari.out");
void Afisare(int top)
{
int i;
for(i=1;i<=top;i++)
fout<<st[i]<<" ";
fout<<"\n";
}
int Valid(int top)
{
return 1;
}
void Back()
{
int cand,top ;
top=1; st[top]=0;
while (top>0)
{
cand=0;
while(!cand && st[top]<n-k+top)
{
st[top]++;
cand=Valid(top);
}
if(!cand ) top--;
else
if(top==k) Afisare(top);
else
{
top++;
st[top]=st[top-1];
}
}
}
int main()
{
fin>>n>>k;
Back();
return 0;
}