-
Notifications
You must be signed in to change notification settings - Fork 0
/
push_swap.c
37 lines (34 loc) · 1.31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tunsal <tunsal@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/10 05:12:06 by tunsal #+# #+# */
/* Updated: 2024/01/13 16:11:50 by tunsal ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int main(int argc, char *argv[])
{
t_stack a;
t_stack b;
init_stacks(&a, &b, argc, argv);
if (stack_is_sorted_asc(&a))
;
else if (stack_get_size(&a) == 2)
{
if (a.data[1] > a.data[0])
sa(&a, TRUE);
}
else if (stack_get_size(&a) == 3)
sort3(&a);
else if (stack_get_size(&a) == 4 || stack_get_size(&a) == 5)
sortn(&a, &b, a.top + 1);
else
mysort(&a, &b);
free(a.data);
free(b.data);
return (0);
}