-
Notifications
You must be signed in to change notification settings - Fork 0
/
pushbtoa.c
37 lines (34 loc) · 1.28 KB
/
pushbtoa.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pushbtoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yhadari <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/30 17:09:04 by yhadari #+# #+# */
/* Updated: 2021/06/03 20:46:49 by yhadari ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
void pushbtoa(t_stack *a, t_stack *b, int c)
{
t_index index;
t_info info;
t_sort tab;
int size;
size = a->top;
index.top = a->data[a->top];
index.zero = a->data[0];
index.size = a->top + 1;
while (b->top >= 0)
{
info = max_min(b, &tab);
checkstackb(a, b, info, &size);
}
size = a->top - size;
while (size--)
ra(a, 1);
if (c == 1)
while (index.size--)
pb(a, b, 1);
}