ajout abs, greater, smaller, sign

This commit is contained in:
hugogogo
2021-07-23 17:13:15 +02:00
parent 26147eeeeb
commit 8fd5257b23
6 changed files with 41 additions and 1 deletions

View File

@@ -102,7 +102,11 @@ SRCS = ft_memset.c \
ft_next_word.c \
ft_convert.c \
ft_flag_transform.c \
ft_flag_transform_bonus.c
ft_flag_transform_bonus.c \
ft_abs.c \
ft_greater.c \
ft_smaller.c \
ft_sign.c
ODIR = ./builds

View File

@@ -107,6 +107,10 @@ void ft_putnbrendl(int n);
void ft_putnbrendl_fd(int n, int fd);
int ft_get_next_line(const int fd, char **line);
char *ft_concat_free(char *str1, char *str2);
int ft_abs(int n);
int ft_greater(int a, int b);
int ft_smaller(int a, int b);
int ft_sign(int i);

8
srcs/ft_abs.c Normal file
View File

@@ -0,0 +1,8 @@
#include "libft.h"
int ft_abs(int n)
{
if (n < 0)
n *= -1;
return (n);
}

8
srcs/ft_greater.c Normal file
View File

@@ -0,0 +1,8 @@
#include "libft.h"
int ft_greater(int a, int b)
{
if (a < b)
return (b);
return (a);
}

8
srcs/ft_sign.c Normal file
View File

@@ -0,0 +1,8 @@
#include "libft.h"
int ft_sign(int i)
{
if (i < 0)
return (-1);
return (1);
}

8
srcs/ft_smaller.c Normal file
View File

@@ -0,0 +1,8 @@
#include "libft.h"
int ft_smaller(int a, int b)
{
if (a > b)
return (b);
return (a);
}