Pagini recente » Cod sursa (job #1397529) | Cod sursa (job #1374910) | Cod sursa (job #635168) | Cod sursa (job #2264251) | Cod sursa (job #2683461)
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <cstring>
#define INF 1e9
#include <string>
#include <stack>
#include <bitset>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <sstream>
using namespace std;
ifstream f("combinari.in");
ofstream g("combinari.out");
typedef long long ll;
int st[19];
int n;
int m;
int valid(int k)
{
return k == m;
}
int solutie(int k)
{
for(int i=1;i<k;i++)
if(st[i]>=st[k])return 0;
return 1;
}
void tipar(int k)
{
for(int i=1;i<=k;i++)
g<<st[i]<<" ";
g<<'\n';
}
void bk(int k)
{
for(int i=1;i<=n;i++)
{
st[k] = i;
if(solutie(k))
{if(valid(k))
tipar(k);
bk(k+1);
}
}
}
int main()
{
f>>n>>m;
bk(1);
return 0;
}