Pagini recente » Cod sursa (job #2814179) | Cod sursa (job #3165490) | Cod sursa (job #535364) | Cod sursa (job #1960661) | Cod sursa (job #2438160)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("combinari.in");
ofstream out("combinari.out");
int n,a[18],fr[18],t;
void bacK(int k)
{
if(k==t+1)
{
for(int j=1;j<=t;j++)
{
out<<a[j]<<' ';
}out<<'\n';
fr[a[t]]=0;
return;
}
for(int i=a[k-1]+1;i<=n;i++)
{
if(!fr[i])
{
a[k]=i;
fr[i]=1;
bacK(k+1);
fr[i]=0;
}
}
}
int main()
{
in>>n>>t;
bacK(1);
return 0;
}