-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathops_swap.c
46 lines (42 loc) · 1.42 KB
/
ops_swap.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ops_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: denizozd <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/02 16:34:33 by denizozd #+# #+# */
/* Updated: 2024/05/26 17:17:12 by denizozd ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void swap(t_node **head)
{
if (stack_size(*head) == 2)
{
*head = (*head)->next;
(*head)->next = (*head)->prev;
(*head)->prev = NULL;
(*head)->next->prev = *head;
(*head)->next->next = NULL;
}
else
{
*head = (*head)->next;
(*head)->prev->next = (*head)->next;
(*head)->prev->prev = *head;
(*head)->next->prev = (*head)->prev;
(*head)->next = (*head)->prev;
(*head)->prev = NULL;
}
}
void sa(t_node **head)
{
swap(head);
ft_printf("sa\n");
}
void sb(t_node **head)
{
swap(head);
ft_printf("sb\n");
}