first commit
This commit is contained in:
17
finish/C00/ex00/ft_putchar.c
Normal file
17
finish/C00/ex00/ft_putchar.c
Normal file
@ -0,0 +1,17 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putchar.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/12 10:32:16 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/12 10:50:35 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
24
finish/C00/ex01/ft_print_alphabet.c
Normal file
24
finish/C00/ex01/ft_print_alphabet.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_alphabet.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/12 11:08:23 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/12 20:50:30 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_alphabet(void)
|
||||
{
|
||||
char i;
|
||||
|
||||
i = 'a';
|
||||
while (i <= 'z')
|
||||
{
|
||||
write(1, &i, 1);
|
||||
i++;
|
||||
}
|
||||
}
|
24
finish/C00/ex02/ft_print_reverse_alphabet.c
Normal file
24
finish/C00/ex02/ft_print_reverse_alphabet.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_reverse_alphabet.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/12 11:08:23 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/15 15:45:54 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_reverse_alphabet(void)
|
||||
{
|
||||
char i;
|
||||
|
||||
i = 'z';
|
||||
while (i >= 'a')
|
||||
{
|
||||
write(1, &i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
24
finish/C00/ex03/ft_print_numbers.c
Normal file
24
finish/C00/ex03/ft_print_numbers.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_numbers.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/12 20:36:08 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/15 15:33:47 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_numbers(void)
|
||||
{
|
||||
char nbr;
|
||||
|
||||
nbr = '0';
|
||||
while (nbr <= '9')
|
||||
{
|
||||
write(1, &nbr, 1);
|
||||
nbr++;
|
||||
}
|
||||
}
|
20
finish/C00/ex04/ft_is_negative.c
Normal file
20
finish/C00/ex04/ft_is_negative.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_is_negative.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/12 20:51:36 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/13 11:47:47 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_is_negative(int n)
|
||||
{
|
||||
if (n < 0)
|
||||
write(1, "N", 1);
|
||||
else
|
||||
write(1, "P", 1);
|
||||
}
|
48
finish/C00/ex05/ft_print_comb.c
Normal file
48
finish/C00/ex05/ft_print_comb.c
Normal file
@ -0,0 +1,48 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_comb.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/12 23:26:35 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/13 11:45:59 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_virgule(char a, char b, char c)
|
||||
{
|
||||
if (!(a == '7' && b == '8' && c == '9'))
|
||||
{
|
||||
write(1, ",", 1);
|
||||
write(1, " ", 1);
|
||||
}
|
||||
}
|
||||
|
||||
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')
|
||||
{
|
||||
write(1, &a, 1);
|
||||
write(1, &b, 1);
|
||||
write(1, &c, 1);
|
||||
ft_print_virgule(a, b, c);
|
||||
c++;
|
||||
}
|
||||
b++;
|
||||
}
|
||||
a++;
|
||||
}
|
||||
}
|
50
finish/C00/ex06/ft_print_comb2.c
Normal file
50
finish/C00/ex06/ft_print_comb2.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_print_comb2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/13 11:13:23 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/16 13:29:28 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_print_nbr(int a, int b)
|
||||
{
|
||||
char c;
|
||||
char d;
|
||||
char e;
|
||||
char f;
|
||||
|
||||
c = a / 10 + 48;
|
||||
d = a % 10 + 48;
|
||||
e = b / 10 + 48;
|
||||
f = b % 10 + 48;
|
||||
write(1, &c, 1);
|
||||
write(1, &d, 1);
|
||||
write(1, " ", 1);
|
||||
write(1, &e, 1);
|
||||
write(1, &f, 1);
|
||||
if (!(c == '9' && d == '8' && e == '9' && f == '9'))
|
||||
write(1, ", ", 2);
|
||||
}
|
||||
|
||||
void ft_print_comb2(void)
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
|
||||
a = 0;
|
||||
while (a <= 98)
|
||||
{
|
||||
b = a + 1;
|
||||
while (b <= 99)
|
||||
{
|
||||
ft_print_nbr(a, b);
|
||||
b++;
|
||||
}
|
||||
a++;
|
||||
}
|
||||
}
|
33
finish/C00/ex07/ft_putnbr.c
Normal file
33
finish/C00/ex07/ft_putnbr.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/13 13:51:06 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/16 13:26:07 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
if (nb == -214783648)
|
||||
{
|
||||
write(1, "-214783648", 10);
|
||||
return ;
|
||||
}
|
||||
if (nb < 0)
|
||||
{
|
||||
write(1, "-", 1);
|
||||
ft_putnbr(nb * -1);
|
||||
}
|
||||
else if (nb < 10)
|
||||
write(1, &(char){nb + 48}, 1);
|
||||
else
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
write(1, &(char){nb % 10 + 48}, 1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user