-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswap_command.c
More file actions
48 lines (42 loc) · 1.54 KB
/
Copy pathswap_command.c
File metadata and controls
48 lines (42 loc) · 1.54 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* swap_command.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tbui-quo <tbui-quo@student.42wolfsburg.d> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/26 22:27:42 by tbui-quo #+# #+# */
/* Updated: 2023/09/26 22:27:42 by tbui-quo ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void swap(t_stack **stack_x)
{
t_stack *first_element;
t_stack *second_element;
first_element = NULL;
second_element = NULL;
if (*stack_x == NULL || (*stack_x)->next == NULL)
return ;
first_element = (*stack_x);
second_element = (*stack_x)->next;
first_element->next = second_element ->next;
second_element->next = first_element;
*stack_x = second_element;
}
void sa(t_stack **stack_a)
{
swap(stack_a);
ft_putstr_fd("sa\n", STDOUT_FILENO);
}
void sb(t_stack **stack_b)
{
swap(stack_b);
ft_putstr_fd("sb\n", STDOUT_FILENO);
}
void ss(t_stack **stack_a, t_stack **stack_b)
{
swap(stack_a);
swap(stack_b);
ft_putstr_fd("ss\n", STDOUT_FILENO);
}