-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse_rotate.c
More file actions
52 lines (46 loc) · 1.43 KB
/
reverse_rotate.c
File metadata and controls
52 lines (46 loc) · 1.43 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* reverse_rotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kikiz <kikiz@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/23 19:17:54 by kikiz #+# #+# */
/* Updated: 2025/03/26 12:42:12 by kikiz ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void ft_reverse(t_stack **stack)
{
t_stack *tmp;
t_stack *last;
tmp = *stack;
if (tmp->next == NULL)
return ;
while (tmp->next->next)
tmp = tmp->next;
last = tmp->next;
tmp->next = NULL;
tmp = *stack;
*stack = last;
last->next = tmp;
}
void ft_rra(t_stack **a, int i)
{
ft_reverse(a);
if (i == 1)
ft_putstr("rra\n");
}
void ft_rrb(t_stack **b, int i)
{
ft_reverse(b);
if (i == 1)
ft_putstr("rrb\n");
}
void ft_rrr(t_stack **a, t_stack **b, int i)
{
ft_reverse(a);
ft_reverse(b);
if (i == 1)
ft_putstr("rrr\n");
}