Cod sursa(job #1114031)

Utilizator robertstrecheStreche Robert robertstreche Data 21 februarie 2014 10:47:22
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#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();
}