Cod sursa(job #1703121)

Utilizator justsomedudePalade Thomas-Emanuel justsomedude Data 16 mai 2016 11:53:23
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.56 kb
#include<fstream>
#define MOD 1999999973
 
using namespace std;
 
ifstream fin  ("combinari.in");
ofstream fout ("combinari.out");
 
int n, st[18], k;
 
void Afisare()
{
    int ok=0;
    for (int i=1; i<=k; i++)
       fout << st[i] << " ";
    fout << "\n";
}
 
void Back(int top)
{
    int i;
    if (top == k+1) Afisare();
    else
      for (i=st[top-1]+1; i<=n-k+top; i++)
        {
          st[top] = i;
          Back(top+1);
        }
}
 
 
int main ()
{
  fin >> n >> k;
  Back(1);
  fin.close();
  fout.close();
  return 0;
}