aboutsummaryrefslogtreecommitdiff
path: root/c00/ex05
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-03 16:37:50 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-03 16:37:50 +0200
commite65f1a0088a86af0426bc523f017631066cc9c42 (patch)
tree38c30d4c5cc60e20b2752cff3b2927af9a16f51a /c00/ex05
parent4205989a932533f528c0fa8f76126a5b57606c0a (diff)
downloadpiscine-e65f1a0088a86af0426bc523f017631066cc9c42.tar.gz
piscine-e65f1a0088a86af0426bc523f017631066cc9c42.tar.bz2
piscine-e65f1a0088a86af0426bc523f017631066cc9c42.zip
c00
Diffstat (limited to 'c00/ex05')
-rw-r--r--c00/ex05/ft_print_comb.c34
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);
-}
-