first commit
This commit is contained in:
57
ended/C00/ex06/ft_print_comb2.c
Normal file
57
ended/C00/ex06/ft_print_comb2.c
Normal file
@ -0,0 +1,57 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void convert_nb(char nb1, char nb1_10, char nb2, char nb2_10)
|
||||
{
|
||||
char r_nb1;
|
||||
char r_nb1_10;
|
||||
char r_nb2;
|
||||
char r_nb2_10;
|
||||
|
||||
r_nb1 = nb1 + 48;
|
||||
r_nb1_10 = nb1_10 + 48;
|
||||
r_nb2 = nb2 + 48;
|
||||
r_nb2_10 = nb2_10 + 48;
|
||||
write(1, &r_nb2_10, 1);
|
||||
write(1, &r_nb2, 1);
|
||||
write(1, " ", 1);
|
||||
write(1, &r_nb1_10, 1);
|
||||
write(1, &r_nb1, 1);
|
||||
}
|
||||
|
||||
void get_nb(char a, char b)
|
||||
{
|
||||
char nb1;
|
||||
char nb2;
|
||||
char nb1_10;
|
||||
char nb2_10;
|
||||
|
||||
nb1 = a % 10;
|
||||
nb2 = b % 10;
|
||||
nb1_10 = a / 10;
|
||||
nb2_10 = b / 10;
|
||||
convert_nb(nb1, nb1_10, nb2, nb2_10);
|
||||
}
|
||||
|
||||
void ft_print_comb2(void)
|
||||
{
|
||||
char nb1;
|
||||
char nb2;
|
||||
|
||||
nb1 = 0;
|
||||
nb2 = 0;
|
||||
while (nb2 <= 98)
|
||||
{
|
||||
nb1 = nb2 + 1;
|
||||
while (nb1 <= 99)
|
||||
{
|
||||
get_nb(nb1, nb2);
|
||||
nb1++;
|
||||
if (nb2 < 98 || nb1 < 99)
|
||||
{
|
||||
write(1, ", ", 2);
|
||||
}
|
||||
}
|
||||
nb2++;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user