-
Notifications
You must be signed in to change notification settings - Fork 0
/
swapping.c
49 lines (43 loc) · 1.56 KB
/
swapping.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
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* swapping.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lstorey <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/14 13:21:53 by lstorey #+# #+# */
/* Updated: 2024/03/26 16:26:42 by lstorey ### ########.fr */
/* */
/* ************************************************************************** */
/* ***************************************** */
/* sa - swapping top 2 nodes of A */
/* sb - swapping top 2 nodes of B */
/* ss - swapping top 2 nodes of A + B */
/* ***************************************** */
#include "push_swap.h"
static void swap(t_ps_list **stack)
{
t_ps_list *tmp;
t_ps_list *pos_2;
tmp = (*stack)->next->next;
pos_2 = (*stack)->next;
pos_2->next = (*stack);
(*stack)->next = tmp;
(*stack) = pos_2;
}
void sa(t_ps_list **stack_a)
{
swap(stack_a);
ft_printf("sa\n");
}
void sb(t_ps_list **stack_b)
{
swap(stack_b);
ft_printf("sb\n");
}
void ss(t_ps_list **stack_a, t_ps_list **stack_b)
{
swap(stack_a);
swap(stack_b);
ft_printf("ss\n");
}