-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrotate.c
46 lines (40 loc) · 1.3 KB
/
rotate.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amtadevo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/22 16:56:08 by amtadevo #+# #+# */
/* Updated: 2022/11/22 16:56:10 by amtadevo ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void rotate(t_stack **top)
{
t_stack *tail;
t_stack *tmp;
if (*top == NULL || (*top)->next == NULL)
return ;
tmp = *top;
*top = (*top)->next;
tail = ft_lstlast(tmp);
tail->next = tmp;
tmp->next = NULL;
}
void ra(t_stack **a)
{
rotate(a);
write(1, "ra\n", 3);
}
void rb(t_stack **b)
{
rotate(b);
write(1, "rb\n", 3);
}
void rr(t_stack *a, t_stack *b)
{
ra(&a);
rb(&b);
write(1, "rr\n", 3);
}