Pagini recente » Cod sursa (job #2971539) | Cod sursa (job #2616428) | Clasament teme2_acmunibuc_2013 | Cod sursa (job #3259196) | Cod sursa (job #2819932)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int n,k;
int st[20];
void Back(int top)
{
if(top==k+1)
{
for(int i=1;i<=top-1;i++)
fout<<st[i]<<" ";
fout<<"\n";
return;
}
for(int i=st[top-1]+1;i<=n;i++)
{
st[top]=i;
Back(top+1);
}
}
int main()
{
fin>>n>>k;
Back(1);
return 0;
}