Pagini recente » Cod sursa (job #1488846) | Cod sursa (job #1843936) | Rating Georgian Marian Comana (GeorgeComana) | Cod sursa (job #768817) | Cod sursa (job #1114031)
#include <fstream>
using namespace std;
ifstream f("combinari.in");
ofstream g("combinari.out");
short n,k;
short sol[20];
int tip()
{
for (short i=1;i<=k;i++)
g<<sol[i]<<" ";
g<<'\n';
}
void back(short x)
{
if (x!=k+1)
{
for (short i=sol[x-1]+1;i<=n;i++)
{
sol[x]=i;
if (x==k)
tip();
else
back(x+1);
}
}
}
int main()
{
f>>n>>k;
back(1);
f.close();
g.close();
}