35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_get_max.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/11/14 16:31:57 by cchauvet #+# #+# */
|
|
/* Updated: 2022/11/28 18:07:53 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "pushswap.h"
|
|
|
|
int ft_get_max_index(int *tab, int size)
|
|
{
|
|
int max;
|
|
int i;
|
|
|
|
i = 1;
|
|
max = 0;
|
|
while (i < size)
|
|
{
|
|
if (tab[max] < tab[i])
|
|
max = i;
|
|
i++;
|
|
}
|
|
return (max);
|
|
}
|
|
|
|
int ft_get_max(int *tab, int size)
|
|
{
|
|
return (tab[ft_get_max_index(tab, size)]);
|
|
}
|