-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.c
48 lines (41 loc) · 1.59 KB
/
push.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abertran <abertran@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/23 19:48:11 by abertran #+# #+# */
/* Updated: 2023/02/23 22:35:46 by abertran ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
/* Pushes the top element of src stack to the top of dest stack. DISTINTO*/
/*tmp = *src;
tmp->next = *dst;
*dst = tmp;
*src = (*src)->next;*/
static void push(t_stack **src, t_stack **dst)
{
t_stack *tmp;
if (*src == NULL)
return ;
tmp = (*src)->next;
(*src)->next = *dst;
*dst = *src;
*src = tmp;
}
/* Pushes the top element of stack b to the top of stack a.
Prints "pa" to the standard output. */
void do_pa(t_stack **stack_a, t_stack **stack_b)
{
push(stack_b, stack_a);
ft_putstr("pa\n");
}
/* Pushes the top element of stack a to the top of stack b.
Prints "pb" to the standard output. */
void do_pb(t_stack **stack_a, t_stack **stack_b)
{
push(stack_a, stack_b);
ft_putstr("pb\n");
}