-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush_swap.c
47 lines (43 loc) · 1.49 KB
/
push_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
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ytaya <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/30 23:30:14 by ytaya #+# #+# */
/* Updated: 2022/02/01 17:31:47 by ytaya ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_push_swap(char **argv, t_type **stackA, t_type **stackB)
{
ft_fill_stack(argv, stackA);
if (!ft_issorted(*stackA))
{
if (ft_lstsize(*stackA) <= 5)
{
ft_small_sort(stackA, stackB);
return ;
}
else if (ft_lstsize(*stackA) <= 100)
ft_finalsort(stackA, stackB);
else
ft_bigsort(stackA, stackB);
}
}
int main(int argc, char **argv)
{
t_type *stacka;
t_type *stackb;
stackb = NULL;
if (argc > 1)
ft_push_swap(&argv[1], &stacka, &stackb);
else
{
ft_putstr("\033[0;33mnote : You need to enter at least 2 \
digits\nusage : ./push_swap 1 ... 2\n");
exit(1);
}
return (0);
}