-
Notifications
You must be signed in to change notification settings - Fork 0
/
rule_swap.c
46 lines (40 loc) · 1.45 KB
/
rule_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rule_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcoskune <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/24 19:52:30 by mcoskune #+# #+# */
/* Updated: 2024/06/29 12:12:50 by mcoskune ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void swap_rule(t_stack *head_x)
{
int temp;
if (head_x == NULL || head_x->next == NULL)
return ;
temp = head_x->value;
head_x->value = head_x->next->value;
head_x->next->value = temp;
temp = head_x->index;
head_x->index = head_x->next->index;
head_x->next->index = temp;
}
void swap_a(t_stack **stack_a)
{
swap_rule(*stack_a);
ft_putstr("sa\n");
}
void swap_b(t_stack **stack_b)
{
swap_rule(*stack_b);
ft_putstr("sb\n");
}
void swap_both(t_stack **stack_a, t_stack **stack_b)
{
swap_rule(*stack_a);
swap_rule(*stack_b);
ft_putstr("ss\n");
}