42_push_swap/ft_get_max.c

37 lines
1.2 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 #+# #+# */
/* Updated: 2022/11/17 00:59:37 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int ft_get_max_index(int *tab)
{
int max;
int i;
int size;
size = ft_get_last_index(tab);
i = 1;
max = 0;
while (i < size)
{
if (tab[max] < tab[i])
max = i;
i++;
}
return (max);
}
int ft_get_max(int *tab)
{
return (tab[ft_get_max_index(tab)]);
}