Test
This commit is contained in:
BIN
ex0/.ft_putnbr.c.swp
Normal file
BIN
ex0/.ft_putnbr.c.swp
Normal file
Binary file not shown.
41
ex0/ft_putnbr.c
Normal file
41
ex0/ft_putnbr.c
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putnbr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/05 13:17:20 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/05 13:37:09 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void ft_putnbr(int nb)
|
||||||
|
{
|
||||||
|
char value;
|
||||||
|
|
||||||
|
if (nb == -2147483648)
|
||||||
|
{
|
||||||
|
write(1, "-2147483648", 11);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
else if (nb < 0)
|
||||||
|
{
|
||||||
|
write(1, "-", 1);
|
||||||
|
nb = -nb;
|
||||||
|
}
|
||||||
|
else if (nb > 9)
|
||||||
|
{
|
||||||
|
ft_putnbr(nb / 10);
|
||||||
|
}
|
||||||
|
value = nb % 10 + '0';
|
||||||
|
write(1, &value, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
ft_putnbr(42);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
BIN
ex1/.ft_print_comb.c.swp
Normal file
BIN
ex1/.ft_print_comb.c.swp
Normal file
Binary file not shown.
52
ex1/ft_print_comb.c
Normal file
52
ex1/ft_print_comb.c
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_print_comb.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/05 09:00:24 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/05 12:01:35 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void print(char a, char b, char c)
|
||||||
|
{
|
||||||
|
write(1, &a, 1);
|
||||||
|
write(1, &b, 1);
|
||||||
|
write(1, &c, 1);
|
||||||
|
if (!(a == '7' && b == '8' && c == '9'))
|
||||||
|
write(1, ", ", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ft_print_comb(void)
|
||||||
|
{
|
||||||
|
char a;
|
||||||
|
char b;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
a = '0';
|
||||||
|
while (a <= '7')
|
||||||
|
{
|
||||||
|
b = a + 1;
|
||||||
|
while (b <= '8')
|
||||||
|
{
|
||||||
|
c = b + 1;
|
||||||
|
while (c <= '9')
|
||||||
|
{
|
||||||
|
print(a, b, c);
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
b++;
|
||||||
|
}
|
||||||
|
a++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
ft_print_comb();
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user