diff options
| author | Cabergs Charles <cacharle@e-r6-p7.s19.be> | 2019-07-03 16:37:50 +0200 |
|---|---|---|
| committer | Cabergs Charles <cacharle@e-r6-p7.s19.be> | 2019-07-03 16:37:50 +0200 |
| commit | 57ae398fc76f5dc53a1a62ceda1b72445273da86 (patch) | |
| tree | 38c30d4c5cc60e20b2752cff3b2927af9a16f51a /c00/ex05 | |
| parent | 7a6ae8c6fa665f0c67fe7b4296778026f08764ce (diff) | |
| download | piscine-57ae398fc76f5dc53a1a62ceda1b72445273da86.tar.gz piscine-57ae398fc76f5dc53a1a62ceda1b72445273da86.tar.bz2 piscine-57ae398fc76f5dc53a1a62ceda1b72445273da86.zip | |
c00
Diffstat (limited to 'c00/ex05')
| -rw-r--r-- | c00/ex05/ft_print_comb.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/c00/ex05/ft_print_comb.c b/c00/ex05/ft_print_comb.c index 1a1ddf3..97a20f2 100644 --- a/c00/ex05/ft_print_comb.c +++ b/c00/ex05/ft_print_comb.c @@ -6,13 +6,22 @@ /* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/02 22:55:29 by cacharle #+# #+# */ -/* Updated: 2019/07/02 23:14:29 by cacharle ### ########.fr */ +/* Updated: 2019/07/03 14:26:35 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include <unistd.h> -void ft_print_comb(void); +void write_separator(void) +{ + char comma; + char space; + + comma = ','; + space = ' '; + write(1, &comma, 1); + write(1, &space, 1); +} void write_xyz_comb(int x, int y, int z) { @@ -26,23 +35,27 @@ void write_xyz_comb(int x, int y, int z) write(1, &x_char, 1); write(1, &y_char, 1); write(1, &z_char, 1); + if (!(x == 7 && y == 8 && z == 9)) + write_separator(); } void ft_print_comb(void) { - char x; - char y; - char z; + int x; + int y; + int z; x = 0; - y = 0; - z = 0; while (x < 10) { + y = x + 1; while (y < 10) { + z = y + 1; while (z < 10) { + if (z == x || z == y) + continue; if (x != y && x != z && y != z) write_xyz_comb(x, y, z); z++; @@ -52,10 +65,3 @@ void ft_print_comb(void) x++; } } - -int main(void) -{ - ft_print_comb(); - return (0); -} - |
