-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_rotate.c
36 lines (32 loc) · 1.23 KB
/
ft_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_rotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: javellis <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 11:30:46 by javellis #+# #+# */
/* Updated: 2023/01/27 18:15:47 by javellis ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_rotate(t_stack **stack)
{
t_stack *first;
t_stack *tmp;
if (*stack && (*stack)->next != NULL)
{
first = *stack;
*stack = (*stack)->next;
first->next = NULL;
tmp = *stack;
while (tmp->next != NULL)
tmp = tmp->next;
tmp->next = first;
}
}
void ft_rr(t_stack **a, t_stack **b)
{
ft_rotate(a);
ft_rotate(b);
}