-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathop_reverse_rot.c
49 lines (43 loc) · 1.46 KB
/
op_reverse_rot.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* op_reverse_rot.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sanmetol <sanmetol@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/30 15:09:58 by sanmetol #+# #+# */
/* Updated: 2024/07/30 16:45:47 by sanmetol ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void reverse_rot(t_node **stack)
{
t_node *last_node;
if (!*stack || !(*stack)->next)
return ;
last_node = find_last_node(*stack);
last_node->prev->next = NULL;
last_node->next = *stack;
last_node->prev = NULL;
(*stack)->prev = last_node;
*stack = last_node;
}
void rra(t_node **a, bool print)
{
reverse_rot(a);
if (print)
write(1, "rra\n", 4);
}
void rrb(t_node **b, bool print)
{
reverse_rot(b);
if (print)
write(1, "rrb\n", 4);
}
void rrr(t_node **a, t_node **b, bool print)
{
reverse_rot(a);
reverse_rot(b);
if (print)
write(1, "rrr\n", 4);
}