forked from sisittu99/push_swap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_op_two.c
73 lines (66 loc) · 2 KB
/
check_op_two.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_op_two.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcerchi <mcerchi@student.42roma.it> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/26 11:14:20 by mcerchi #+# #+# */
/* Updated: 2022/02/26 14:48:08 by mcerchi ### ########.fr */
/* */
/* ************************************************************************** */
#include "./libft/libft.h"
void ft_ra_check(t_list **stack_a)
{
t_list *last;
t_list *first;
if (*stack_a == NULL || (*stack_a)->next == NULL)
return ;
last = *stack_a;
first = *stack_a;
while (last->next != NULL)
last = last->next;
*stack_a = first->next;
first->next = NULL;
last->next = first;
return ;
}
void ft_rb_check(t_list **stack_b)
{
t_list *last;
t_list *first;
if (*stack_b == NULL || (*stack_b)->next == NULL)
return ;
last = *stack_b;
first = *stack_b;
while (last->next != NULL)
last = last->next;
*stack_b = first->next;
first->next = NULL;
last->next = first;
return ;
}
void ft_rr_check(t_list **stack_a, t_list **stack_b)
{
t_list *last;
t_list *first;
if (*stack_a == NULL || (*stack_a)->next == NULL)
return ;
last = *stack_a;
first = *stack_a;
while (last->next != NULL)
last = last->next;
*stack_a = first->next;
first->next = NULL;
last->next = first;
if (*stack_b == NULL || (*stack_b)->next == NULL)
return ;
last = *stack_b;
first = *stack_b;
while (last->next != NULL)
last = last->next;
*stack_b = first->next;
first->next = NULL;
last->next = first;
return ;
}