Cod sursa(job #735434)
| Utilizator | Data | 16 aprilie 2012 14:35:39 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.62 kb |
#include <stdio.h>
using namespace std;
char n, k;
char solutie[19];
void scriesolutie()
{
for (char i = 1; i <= k-1; ++i)
{
printf("%hd ", solutie[i]);
}
printf("%hd\n", solutie[k]);
}
void back(char pas)
{
if (pas == k)
{
scriesolutie();
}
else
{
for (char i = solutie[pas] + 1; i <= n; ++i)
{
solutie[pas+1] = i;
back(pas+1);
}
}
}
int main()
{
freopen("combinari.in", "r", stdin);
freopen("combinari.out", "w", stdout);
scanf("%hd%hd", &n, &k);
back(0);
return 0;
}
