Cod sursa(job #531345)

Utilizator hiticas_abelhiticasabel hiticas_abel Data 9 februarie 2011 15:08:28
Problema Combinari Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.52 kb
#include<iostream.h>
#include<fstream.h>
using namespace std;
int st[100],n,k;
ifstream f("combinari.in");
ofstream g("combinari.out");
void afisare(int p)
{
     int i;
       for(i=1;i<=k;i++)
       g<<st[i]<<" ";
       g<<"\n";
}
void back(int p)
{
     int pval;
     for(pval=st[p-1]+1;pval<=n;pval++)
     {
        st[p]=pval;
     if(p==k)
     afisare(p);
     else
     back(p+1);
     }
}
int main()
{
    f>>n;
       f>>k;
         back(1);
             return 0;
    //system("pause");
}