Cod sursa(job #1685006)

Utilizator codrin18Diac Eugen Codrin codrin18 Data 11 aprilie 2016 13:54:13
Problema Combinari Scor 80
Compilator cpp Status done
Runda Arhiva educationala Marime 0.6 kb
#include <iostream>
#include <fstream>
using namespace std;
int st[100],n,k;
ifstream f("combinari.in");
ofstream g("combinari.out");
bool valid (int p)
{
    bool ok; int i;
    ok=true;
    if (st[p]<=st[p-1]) ok=false;
    return ok;
}
void tipar(int p)
{
    int i;
    for (i=1;i<=k;i++)
         g<<st[i]<<" ";
    g<<endl;
}
void bkt (int p)
{
    int a;
    for (a=1;a<=n;a++)
    {
        st[p]=a;
        if (valid(p))
        {
            if (p==k) tipar(p);
            else bkt(p+1);
        }
    }
}
int main()
{
    f>>n>>k;
    bkt(1);
    return 0;
}