-
Notifications
You must be signed in to change notification settings - Fork 0
/
reverse_rotate.c
47 lines (41 loc) · 1.41 KB
/
reverse_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
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* reverse_rotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vmustone <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/11 16:17:06 by vmustone #+# #+# */
/* Updated: 2023/05/11 21:17:31 by vmustone ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void reverse_rotate(t_stack *stack)
{
int tmp;
int i;
i = 0;
tmp = stack->ptr[stack->size - 1];
while (i < stack->size - 1)
{
stack->ptr[stack->size - 1 - i] = stack->ptr[stack->size - i - 2];
i++;
}
stack->ptr[0] = tmp;
}
void rra(t_stack *stack_a)
{
reverse_rotate(stack_a);
ft_printf("rra\n");
}
void rrb(t_stack *stack_b)
{
reverse_rotate(stack_b);
ft_printf("rrb\n");
}
void rrr(t_stack *stack_a, t_stack *stack_b)
{
reverse_rotate(stack_a);
reverse_rotate(stack_b);
ft_printf("rrr\n");
}