42/d09/ex17/ft_max.c

30 lines
1.1 KiB
C
Raw Permalink Normal View History

2016-11-20 02:20:23 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_max.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 10:45:30 by gtertysh #+# #+# */
/* Updated: 2016/11/04 11:04:53 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
int ft_max(int *tab, int length)
{
int i;
int max;
i = 1;
if (length == 0)
return (0);
max = tab[0];
while (i < length)
{
if (tab[i] > max)
max = tab[i];
i++;
}
return (max);
}