diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-28 13:47:11 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-28 13:47:11 +0200 |
| commit | e534578eecebd27c4e7e235ce85961446e6c2e43 (patch) | |
| tree | e581555b571035e6633134e1ed9c6280531a18a3 /c00/ex08/ft_print_combn.c | |
| parent | 8172a7f70e35942cf102fb07963687d9ddace818 (diff) | |
| download | piscine-e534578eecebd27c4e7e235ce85961446e6c2e43.tar.gz piscine-e534578eecebd27c4e7e235ce85961446e6c2e43.tar.bz2 piscine-e534578eecebd27c4e7e235ce85961446e6c2e43.zip | |
test commit for reload branch
Diffstat (limited to 'c00/ex08/ft_print_combn.c')
| -rw-r--r-- | c00/ex08/ft_print_combn.c | 40 |
1 files changed, 29 insertions, 11 deletions
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 <unistd.h>*/ +#include <unistd.h> -/*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); +} |
