From 57ae398fc76f5dc53a1a62ceda1b72445273da86 Mon Sep 17 00:00:00 2001 From: Cabergs Charles Date: Wed, 3 Jul 2019 16:37:50 +0200 Subject: c00 --- c00/ex05/ft_print_comb.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'c00/ex05') 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 +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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 -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); -} - -- cgit