Add ft_print_comb2
This commit is contained in:
parent
ba2b0c541e
commit
e3032cac96
|
@ -0,0 +1,64 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_reverse_alphabet.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/15 21:50:37 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/16 05:00:01 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
char digit_to_char(char c)
|
||||
{
|
||||
return (c + '0');
|
||||
}
|
||||
|
||||
void print_a_and_b(int a, int b)
|
||||
{
|
||||
char a_tenth;
|
||||
char b_tenth;
|
||||
|
||||
a_tenth = digit_to_char(a / 10);
|
||||
a = digit_to_char(a % 10);
|
||||
b_tenth = digit_to_char(b / 10);
|
||||
b = digit_to_char(b % 10);
|
||||
write(1, &a_tenth, 1);
|
||||
write(1, &a, 1);
|
||||
write(1, " ", 1);
|
||||
write(1, &b_tenth, 1);
|
||||
write(1, &b, 1);
|
||||
if (a != 98)
|
||||
{
|
||||
write(1, ", ", 2);
|
||||
}
|
||||
}
|
||||
|
||||
void ft_print_comb2(void)
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
|
||||
a = 0;
|
||||
while (a <= 98)
|
||||
{
|
||||
b = a + 1;
|
||||
while (b <= 99)
|
||||
{
|
||||
print_a_and_b(a, b);
|
||||
b++;
|
||||
}
|
||||
a++;
|
||||
}
|
||||
}
|
||||
|
||||
/* ////
|
||||
int main(void)
|
||||
{
|
||||
ft_print_comb2();
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
Loading…
Reference in New Issue