From e534578eecebd27c4e7e235ce85961446e6c2e43 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 28 Jul 2019 13:47:11 +0200 Subject: test commit for reload branch --- c00/ex08/ft_print_combn.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'c00/ex08') diff --git a/c00/ex08/ft_print_combn.c b/c00/ex08/ft_print_combn.c index 975c306..c7b415f 100644 --- a/c00/ex08/ft_print_combn.c +++ b/c00/ex08/ft_print_combn.c @@ -10,16 +10,34 @@ /* */ /* ************************************************************************** */ -/*#include */ +#include -/*void ft_print_combn(int n)*/ -/*{*/ - /*int i;*/ +void ft_putchar(char c) +{ + write(STDOUT_FILENO, &c, 1); +} - /*if (n == 0)*/ - /*return ;*/ - /*i = 0;*/ - /*while (i < 10)*/ - /*{*/ - /*}*/ -/*}*/ +void comb(int start, int n) +{ + int i; + + if (n == 0) + { + ft_putchar(','); + ft_putchar(' '); + return ; + } + i = start + 1; + while (i < 10) + { + ft_putchar(start + '0'); + ft_putchar(i + '0'); + comb(i, n - 1); + i++; + } +} + +void ft_print_combn(int n) +{ + comb(0, n); +} -- cgit