35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_get_min.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/11/15 13:20:22 by cchauvet #+# #+# */
|
|
/* Updated: 2022/11/28 16:46:47 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "pushswap.h"
|
|
|
|
int get_min_index(int *tab, int size)
|
|
{
|
|
int i;
|
|
int min;
|
|
|
|
min = 0;
|
|
i = 1;
|
|
while (i < size)
|
|
{
|
|
if (tab[min] > tab[i])
|
|
min = i;
|
|
i++;
|
|
}
|
|
return (min);
|
|
}
|
|
|
|
int get_min(int *tab, int size)
|
|
{
|
|
return (tab[get_min_index(tab, size)]);
|
|
}
|