-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_mvt_push.c
54 lines (49 loc) · 1.56 KB
/
ft_mvt_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
49
50
51
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_mvt_push.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: flormich <flormich@student.42wolfsburg.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/25 20:30:12 by flormich #+# #+# */
/* Updated: 2021/08/01 22:29:25 by flormich ### ########.fr */
/* */
/* ************************************************************************** */
#include"push_swap.h"
/* write(1, "\nAFTER PUSH\n", 12);
ft_print_stack(stack_a, 'A');
ft_print_stack(stack_b, 'B');*/
static void ft_push(t_stack *from, t_stack *to)
{
int i;
i = 0;
while (i < to->size)
{
to->elt[to->size - i] = to->elt[to->size - 1 - i];
i++;
}
to->elt[0] = from->elt[0];
to->size++;
from->size--;
i = 0;
while (i < from->size)
{
from->elt[i] = from->elt[i + 1];
i++;
}
from->elt[from->size] = '\0';
}
void ft_pilote_push(t_stack *a, t_stack *b, int which, int print)
{
if (which == PA)
ft_push(b, a);
if (which == PB)
ft_push(a, b);
if (print == 1)
{
if (which == PA)
write(1, "pa\n", 3);
else if (which == PB)
write(1, "pb\n", 3);
}
}