Cod sursa(job #2683461)

Utilizator martinmiere133Cranga Antonio martinmiere133 Data 11 decembrie 2020 14:18:40
Problema Combinari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.96 kb
#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;
}