-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_rrotate.c
More file actions
45 lines (40 loc) · 1.32 KB
/
stack_rrotate.c
File metadata and controls
45 lines (40 loc) · 1.32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* stack_rrotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yaqliu <yaqliu@student.42barcelona.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/08 23:22:53 by yaqliu #+# #+# */
/* Updated: 2026/02/12 14:28:05 by yaqliu ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
int rrotate(t_stack **stack)
{
t_stack *last;
t_stack *new_last;
if (!stack || !(*stack) || !(*stack)->next)
return (0);
last = *stack;
new_last = NULL;
while (last->next)
{
new_last = last;
last = last->next;
}
new_last->next = NULL;
last->next = *stack;
*stack = last;
return (1);
}
void rra(t_stack **a)
{
if (rrotate(a))
write(1, "rra\n", 4);
}
void rrb(t_stack **b)
{
if (rrotate(b))
write(1, "rrb\n", 4);
}