0
0
This commit is contained in:
Guy Baconniere
2021-08-19 18:28:52 +02:00
parent ca23b5f895
commit 5aa02c94b5
8 changed files with 157 additions and 25 deletions

View File

@@ -6,27 +6,35 @@
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/18 18:13:35 by gbaconni #+# #+# */
/* Updated: 2021/08/18 18:32:22 by gbaconni ### ########.fr */
/* Updated: 2021/08/19 16:10:59 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
static int ft_abs(int n)
{
if (n < 0)
n = -n;
return (n);
}
int *ft_range(int min, int max)
{
int *range;
int size;
int i;
if (min < max)
size = (max - min) + 1;
range = NULL;
if (min >= max)
return (range);
else
return (NULL);
size = ft_abs(max - min);
range = (int *) malloc(size * sizeof(int));
i = 0;
while (i < size)
{
range[i] = min + i;
range[i] = 1 + min + i;
i++;
}
return (range);