-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
58 lines (52 loc) · 1.6 KB
/
main.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nenvoy <nenvoy@student.21-school.ru> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/15 16:46:34 by nenvoy #+# #+# */
/* Updated: 2021/12/15 16:46:43 by nenvoy ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void free_node(t_list *node)
{
t_list *tmp;
while (node)
{
tmp = node;
node = node->next;
if (tmp)
free(tmp);
}
node = NULL;
}
void sort(int argc, t_list **stack_a, t_list **stack_b)
{
if (argc == 3)
sort_two(stack_a);
if (argc == 4)
sort_three(stack_a);
if (argc >= 5 && argc <= 7)
sort_four_six(stack_a, stack_b);
if (argc > 7 && argc <= 101)
sort_100(stack_a, stack_b);
if (argc > 101)
sort_500(stack_a, stack_b);
}
int main(int argc, char **argv)
{
t_list *stack_a;
t_list *stack_b;
if (argc > 2)
{
stack_a = create_node(argc, argv);
check(stack_a);
sort_id(&stack_a, argc);
stack_b = NULL;
sort(argc, &stack_a, &stack_b);
free_node(stack_a);
}
return (0);
}