42_push_swap/ft_get_bit_max.c

32 lines
1.1 KiB
C
Raw Normal View History

2022-11-23 15:44:27 -05:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
2022-11-29 08:06:22 -05:00
/* ft_get_bit_max.c :+: :+: :+: */
2022-11-23 15:44:27 -05:00
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
2022-11-29 08:06:22 -05:00
/* Created: 2022/11/28 16:22:14 by cchauvet #+# #+# */
/* Updated: 2022/11/28 17:56:32 by cchauvet ### ########.fr */
2022-11-23 15:44:27 -05:00
/* */
/* ************************************************************************** */
#include "pushswap.h"
2022-11-29 08:06:22 -05:00
int ft_get_bit_max(int *tab)
2022-11-23 15:44:27 -05:00
{
2022-11-29 08:06:22 -05:00
int i;
int max;
2022-11-23 15:44:27 -05:00
2022-11-29 08:06:22 -05:00
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);
2022-11-23 15:44:27 -05:00
}