42_push_swap/ft_is_sorted.c
Camille Chauvet 55119130da ca marche
2022-12-09 19:13:15 +01:00

32 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is_sorted.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/29 14:41:08 by cchauvet #+# #+# */
/* Updated: 2022/12/09 18:06:59 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int ft_is_sorted(unsigned int *tab)
{
int i;
if (ft_tablen(tab) == 0)
return (0);
if (ft_tablen(tab) == 1)
return (1);
i = 1;
while (tab[i] != STOP_VALUE)
{
if (tab[i] != tab[i - 1] + 1)
return (0);
i++;
}
return (1);
}