From 1f234c4e589cc9e723bfef66cca7c923821f5484 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Sun, 25 Jul 2021 12:49:58 +0200 Subject: [PATCH] ajout sqartroot --- Makefile | 3 ++- includes/libft.h | 1 + srcs/ft_sqrt.c | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 srcs/ft_sqrt.c diff --git a/Makefile b/Makefile index 147c2f3..69975a7 100644 --- a/Makefile +++ b/Makefile @@ -106,7 +106,8 @@ SRCS = ft_memset.c \ ft_abs.c \ ft_greater.c \ ft_smaller.c \ - ft_sign.c + ft_sign.c \ + ft_sqrt.c ODIR = ./builds diff --git a/includes/libft.h b/includes/libft.h index 18db2c6..6cd98a7 100644 --- a/includes/libft.h +++ b/includes/libft.h @@ -108,5 +108,6 @@ int ft_abs(int n); int ft_greater(int a, int b); int ft_smaller(int a, int b); int ft_sign(int i); +int ft_sqrt(int i); #endif diff --git a/srcs/ft_sqrt.c b/srcs/ft_sqrt.c new file mode 100644 index 0000000..04c1483 --- /dev/null +++ b/srcs/ft_sqrt.c @@ -0,0 +1,15 @@ +#include "libft.h" + +/* +** return the square root of nb +** or the integer value of it +*/ +int ft_sqrt(int nb) +{ + int i; + + i = 0; + while ((i*i) < nb) + i++; + return (i); +}