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-09 13:13:15 -05:00
|
|
|
/* Updated: 2022/12/09 18:06:59 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-09 13:13:15 -05:00
|
|
|
if (ft_tablen(tab) == 0)
|
|
|
|
return (0);
|
|
|
|
if (ft_tablen(tab) == 1)
|
|
|
|
return (1);
|
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);
|
|
|
|
}
|