Cod sursa(job #539608)
| Utilizator | Data | 23 februarie 2011 09:30:31 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include<iostream>
#include<fstream>
using namespace std;
int N,K,st[10];fstream f("combinari.in",ios::in);
fstream g("combinari.out",ios::out);
int tipar(int p)
{
for(int i=1;i<=K;i++)
g<<st[i]<<" ";
g<<'\n';
}
int bkt(int p)
{
for(int val=st[p-1]+1;val<=N;val++)
{st[p]=val;
if(p==K) tipar(p);
else bkt(p+1);}
}
int main()
{
f>>N>>K;
st[0]=0;
bkt(1);}