69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_print_comb.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/06/04 14:57:05 by whaffman #+# #+# */
|
|
/* Updated: 2024/06/04 16:50:34 by whaffman ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <unistd.h>
|
|
|
|
void write_number(int n)
|
|
{
|
|
char c;
|
|
|
|
if (n >= 0 && n <= 9)
|
|
{
|
|
c = n + 48;
|
|
write(1, &c, 1);
|
|
}
|
|
}
|
|
|
|
void write_numbers(int a, int b, int c)
|
|
{
|
|
write_number(a);
|
|
write_number(b);
|
|
write_number(c);
|
|
if (a != 7 || b != 8 || c != 9)
|
|
{
|
|
write(1, ", ", 2);
|
|
}
|
|
}
|
|
|
|
void ft_print_comb(void)
|
|
{
|
|
int a;
|
|
int b;
|
|
int c;
|
|
|
|
a = 0;
|
|
b = 0;
|
|
c = 0;
|
|
while (a <= 7)
|
|
{
|
|
b = a + 1;
|
|
while (b <= 8)
|
|
{
|
|
c = b + 1;
|
|
while (c <= 9)
|
|
{
|
|
write_numbers(a, b, c);
|
|
c++;
|
|
}
|
|
b++;
|
|
}
|
|
a++;
|
|
}
|
|
}
|
|
/*
|
|
int main(void)
|
|
{
|
|
ft_print_comb();
|
|
return (0);
|
|
}
|
|
*/
|