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-12-06 11:35:45 -05:00
|
|
|
/* Updated: 2022/12/02 20:33:17 by cchauvet ### ########.fr */
|
2022-11-23 15:44:27 -05:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#include "pushswap.h"
|
|
|
|
|
2022-12-06 11:35:45 -05:00
|
|
|
int ft_get_max_index(long 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-12-06 11:35:45 -05:00
|
|
|
int ft_get_max(unsigned int *tab)
|
2022-11-23 15:44:27 -05:00
|
|
|
{
|
2022-12-06 11:35:45 -05:00
|
|
|
unsigned int max;
|
|
|
|
|
|
|
|
max = *tab;
|
|
|
|
tab++;
|
|
|
|
while (*tab != STOP_VALUE)
|
|
|
|
{
|
|
|
|
if (*tab > max)
|
|
|
|
max = *tab;
|
|
|
|
tab++;
|
|
|
|
}
|
|
|
|
return (max);
|
2022-11-23 15:44:27 -05:00
|
|
|
}
|