1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_comb.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/02 22:55:29 by cacharle #+# #+# */
/* Updated: 2019/07/03 14:26:35 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
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)
{
char x_char;
char y_char;
char z_char;
x_char = x + '0';
y_char = y + '0';
z_char = z + '0';
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)
{
int x;
int y;
int z;
x = 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++;
}
y++;
}
x++;
}
}
|