-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.c
67 lines (62 loc) · 1.61 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rlechapt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/01/24 04:33:41 by rlechapt #+# #+# */
/* Updated: 2015/03/04 18:52:18 by rlechapt ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void push_a(t_env *e, t_flags *f)
{
int i;
if (e->len_b == 0)
return ;
i = e->len_a;
while (i > 0)
{
e->pile_a[i] = e->pile_a[i - 1];
i--;
}
e->pile_a[0] = e->pile_b[0];
e->len_a += 1;
e->len_b -= 1;
i = 0;
while (i < e->len_b)
{
e->pile_b[i] = e->pile_b[i + 1];
i++;
}
e->count += 1;
ft_putstr("pa ");
if (f->v == 1)
stack_status(e);
}
void push_b(t_env *e, t_flags *f)
{
int i;
if (e->len_a == 0)
return ;
i = e->len_b;
while (i > 0)
{
e->pile_b[i] = e->pile_b[i - 1];
i--;
}
e->pile_b[0] = e->pile_a[0];
e->len_b += 1;
e->len_a -= 1;
i = 0;
while (i < e->len_a)
{
e->pile_a[i] = e->pile_a[i + 1];
i++;
}
e->count += 1;
ft_putstr("pb ");
if (f->v == 1)
stack_status(e);
}