42_push_swap/ft_get_bit_max.c
Camille Chauvet f4bd2c9432 init
2022-11-29 14:06:22 +01:00

32 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_get_bit_max.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/28 16:22:14 by cchauvet #+# #+# */
/* Updated: 2022/11/28 17:56:32 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int ft_get_bit_max(int *tab)
{
int i;
int max;
if (tab[0] == -1)
return (INT_MIN);
max = tab[0];
i = 1;
while (tab[i] != -1)
{
if (ft_bit_finder(tab[i], 1) < ft_bit_finder(max, 1))
max = tab[i];
i++;
}
return (max);
}