45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_get_max.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/11/14 16:31:57 by cchauvet #+# #+# */
|
|
/* Updated: 2022/12/02 20:33:17 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "pushswap.h"
|
|
|
|
int ft_get_max_index(long 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(unsigned int *tab)
|
|
{
|
|
unsigned int max;
|
|
|
|
max = *tab;
|
|
tab++;
|
|
while (*tab != STOP_VALUE)
|
|
{
|
|
if (*tab > max)
|
|
max = *tab;
|
|
tab++;
|
|
}
|
|
return (max);
|
|
}
|