-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverif.c
53 lines (49 loc) · 1.4 KB
/
verif.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* verif.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wdelaros <wdelaros@student.42quebec.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/16 10:29:04 by wdelaros #+# #+# */
/* Updated: 2023/03/16 11:23:15 by wdelaros ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int verif_number(t_pile *a, t_pile *b)
{
if (ft_pilesize(b) > 0)
return (0);
while (a->next != NULL)
{
if (a->nbr > a->next->nbr)
return (0);
a = a->next;
}
return (1);
}
int verif_pilea(t_pile *a, int bool)
{
while (a->next)
{
if (a->nbr > a->next->nbr)
{
if (!a->next->next && bool)
return (2);
else
return (0);
}
a = a->next;
}
return (1);
}
int verif_pileb(t_pile *b)
{
while (b->next)
{
if (b->nbr < b->next->nbr)
return (0);
b = b->next;
}
return (1);
}