Cod sursa(job #868014)
| Utilizator | Data | 30 ianuarie 2013 16:08:02 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
#include<stdio.h>
using namespace std;
ifstream fin("combinari.in");
ofstream fout ("combinari.out");
int n,h,k;
int comb[18];
void compute_combinations (int c)
{
int i;
for (i=comb[c-1]+1;i<=n;i++)
{
comb[c]=i;
if (c<k) compute_combinations (c+1);
else {for (h=1;h<=k;h++) fout<<comb[h]<<" ";fout<<"\n";}
}
}
int main()
{
fin>>n>>k;
compute_combinations (1);
}