-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswaps.c
46 lines (40 loc) · 1.38 KB
/
swaps.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* swaps.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: joalmeid <joalmeid@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/27 18:02:03 by joalmeid #+# #+# */
/* Updated: 2023/03/07 13:09:39 by joalmeid ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void swap_next_node(t_list **stack)
{
t_list *tmp;
t_list *tmp2;
if ((*stack)->next == NULL)
return ;
tmp = *stack;
*stack = (*stack)->next;
tmp2 = (*stack)->next;
(*stack)->next = tmp;
tmp->next = tmp2;
}
void sa(t_list **stack_a)
{
swap_next_node(stack_a);
print_action("sa\n");
}
void sb(t_list **stack_b)
{
swap_next_node(stack_b);
print_action("sb\n");
}
void ss(t_list **stack_a, t_list **stack_b)
{
swap_next_node(stack_a);
swap_next_node(stack_b);
print_action("ss\n");
}