-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
48 lines (42 loc) · 1.44 KB
/
main.c
File metadata and controls
48 lines (42 loc) · 1.44 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aylaaouf <aylaaouf@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/07 00:36:16 by aylaaouf #+# #+# */
/* Updated: 2025/01/24 13:26:01 by aylaaouf ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
#include "utils/utils.h"
void algo(t_stack_node **stack_a, t_stack_node **stack_b)
{
if (!is_sorted(*stack_a))
sort_stack(stack_a, stack_b);
}
void free_stack(t_stack_node **stack)
{
t_stack_node *tmp;
while (*stack)
{
tmp = *stack;
*stack = (*stack)->next;
free(tmp);
}
}
int main(int ac, char **av)
{
t_stack_node *stack_a;
t_stack_node *stack_b;
stack_a = NULL;
stack_b = NULL;
if (ac == 1)
exit(0);
valid_input(av, ac);
into_stack(ac, av, &stack_a);
algo(&stack_a, &stack_b);
free_stack(&stack_a);
free_stack(&stack_b);
}