42_push_swap/ft_get_max.c

35 lines
1.1 KiB
C
Raw Normal View History

2022-11-23 15:44:27 -05:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_get_max.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/14 16:31:57 by cchauvet #+# #+# */
2022-11-29 08:06:22 -05:00
/* Updated: 2022/11/28 18:07:53 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_max_index(int *tab, int size)
2022-11-23 15:44:27 -05:00
{
int max;
int i;
i = 1;
max = 0;
while (i < size)
{
if (tab[max] < tab[i])
max = i;
i++;
}
return (max);
}
2022-11-29 08:06:22 -05:00
int ft_get_max(int *tab, int size)
2022-11-23 15:44:27 -05:00
{
2022-11-29 08:06:22 -05:00
return (tab[ft_get_max_index(tab, size)]);
2022-11-23 15:44:27 -05:00
}