-
Notifications
You must be signed in to change notification settings - Fork 0
/
rotate.c
47 lines (41 loc) · 1.32 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
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vmustone <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/11 16:03:12 by vmustone #+# #+# */
/* Updated: 2023/05/11 21:30:01 by vmustone ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void rotate(t_stack *stack)
{
int tmp;
int i;
i = 0;
tmp = stack->ptr[0];
while (i < stack->size)
{
stack->ptr[i] = stack->ptr[i + 1];
i++;
}
stack->ptr[i - 1] = tmp;
}
void ra(t_stack *stack_a)
{
rotate(stack_a);
ft_printf("ra\n");
}
void rb(t_stack *stack_b)
{
rotate(stack_b);
ft_printf("rb\n");
}
void rr(t_stack *stack_a, t_stack *stack_b)
{
rotate(stack_a);
rotate(stack_b);
ft_printf("rr\n");
}