Refactor ft_print_comb.c

This commit is contained in:
tosu 2023-03-17 02:16:53 +01:00
parent 04b4291970
commit ba2b0c541e
1 changed files with 31 additions and 26 deletions

View File

@ -12,34 +12,39 @@
#include <unistd.h> #include <unistd.h>
void ft_print_comb(void) void print_abc(char a, char b, char c)
{ {
int a; write(1, &a, 1);
int b; write(1, &b, 1);
int c; write(1, &c, 1);
if (a != '7')
{
write(1, ", ", 2);
}
}
a = '0'; void ft_print_comb(void)
while (a <= '7') {
{ int a;
b = a + 1; int b;
while (b <= '8') int c;
{
c = b + 1; a = '0';
while (c <= '9') while (a <= '7')
{ {
write(1, &a, 1); b = a + 1;
write(1, &b, 1); while (b <= '8')
write(1, &c, 1); {
if (a != '7') c = b + 1;
{ while (c <= '9')
write(1, ", ", 2); {
} print_abc(a, b, c);
c++; c++;
} }
b++; b++;
} }
a++; a++;
} }
} }
/* //// /* ////