-
Notifications
You must be signed in to change notification settings - Fork 0
/
swap.c
55 lines (46 loc) · 1.52 KB
/
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
47
48
49
50
51
52
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kristori <kristori@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/19 13:11:39 by kristori #+# #+# */
/* Updated: 2022/12/19 16:23:31 by kristori ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_sa(t_stack **stack_a)
{
t_stack *tmp;
tmp = *stack_a;
ft_swap(&tmp->data, &tmp->next->data);
tmp = tmp->next->next;
write(1, "sa\n", 3);
}
void ft_sb(t_stack **stack_b)
{
t_stack *tmp;
tmp = *stack_b;
ft_swap(&tmp->data, &tmp->next->data);
tmp = tmp->next->next;
write(1, "sb\n", 3);
}
void ft_ss(t_stack **stack_a, t_stack **stack_b)
{
t_stack *tmp;
tmp = *stack_a;
ft_swap(&tmp->data, &tmp->next->data);
tmp = tmp->next->next;
tmp = *stack_b;
ft_swap(&tmp->data, &tmp->next->data);
tmp = tmp->next->next;
write(1, "ss\n", 3);
}
void ft_swap(int *a, int *b)
{
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
}