42_push_swap/ft_is_sorted.c

28 lines
1.1 KiB
C
Raw Normal View History

2022-11-30 07:21:32 -05:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is_sorted.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/29 14:41:08 by cchauvet #+# #+# */
2022-12-06 11:35:45 -05:00
/* Updated: 2022/12/06 13:30:52 by cchauvet ### ########.fr */
2022-11-30 07:21:32 -05:00
/* */
/* ************************************************************************** */
#include "pushswap.h"
2022-12-01 11:15:17 -05:00
int ft_is_sorted(unsigned int *tab)
2022-11-30 07:21:32 -05:00
{
2022-12-01 11:15:17 -05:00
int i;
2022-11-30 07:21:32 -05:00
2022-12-06 11:35:45 -05:00
i = 1;
2022-12-01 11:15:17 -05:00
while (tab[i] != STOP_VALUE)
2022-11-30 07:21:32 -05:00
{
2022-12-06 11:35:45 -05:00
if (tab[i] != tab[i - 1] + 1)
2022-11-30 07:21:32 -05:00
return (0);
i++;
}
return (1);
}