42_push_swap/ft_get_min.c

35 lines
1.1 KiB
C
Raw Normal View History

2022-11-23 15:44:27 -05:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_get_min.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/15 13:20:22 by cchauvet #+# #+# */
2022-11-29 08:06:22 -05:00
/* Updated: 2022/11/28 16:46:47 by cchauvet ### ########.fr */
2022-11-23 15:44:27 -05:00
/* */
/* ************************************************************************** */
#include "pushswap.h"
2022-11-29 08:06:22 -05:00
int get_min_index(int *tab, int size)
2022-11-23 15:44:27 -05:00
{
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)
{
2022-11-29 08:06:22 -05:00
return (tab[get_min_index(tab, size)]);
2022-11-23 15:44:27 -05:00
}