-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_r_rotate.c
More file actions
62 lines (56 loc) · 1.73 KB
/
utils_r_rotate.c
File metadata and controls
62 lines (56 loc) · 1.73 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
53
54
55
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_r_rotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: uyilmaz <uyilmaz@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/27 10:03:34 by uyilmaz #+# #+# */
/* Updated: 2023/02/27 15:54:20 by uyilmaz ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void rra(t_list **stack_a)
{
t_list **nuller;
t_list *temp_last;
t_list *temp_a;
if (!(*stack_a) || !((*stack_a)->next))
return ;
temp_a = *stack_a;
nuller = stack_a;
temp_last = (*stack_a)->next;
while (temp_last->next)
{
temp_last = temp_last->next;
*nuller = (*nuller)->next;
}
(*nuller)->next = NULL;
*stack_a = temp_last;
(*stack_a)->next = temp_a;
}
void rrb(t_list **stack_b)
{
t_list **nuller;
t_list *temp_last;
t_list *temp_b;
if (!(*stack_b) || !((*stack_b)->next))
return ;
temp_b = *stack_b;
nuller = stack_b;
temp_last = (*stack_b)->next;
while (temp_last->next)
{
temp_last = temp_last->next;
*nuller = (*nuller)->next;
}
(*nuller)->next = NULL;
*stack_b = temp_last;
(*stack_b)->next = temp_b;
}
void rrr(t_list **stack_a, t_list **stack_b)
{
rra(stack_a);
rrb(stack_b);
ft_putstr("rrr\n");
}