-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreat_stack.c
86 lines (78 loc) · 1.69 KB
/
creat_stack.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "push_swap.h"
t_list *creat_stack(int argc, char **argv)
{
t_list *head;
t_list *last;
int i;
i = 1;
if (argc >= 2)
{
last = creat_node(ft_atoi(argv[i++]));
head = last;
while (i < argc)
{
last->next = creat_node(ft_atoi(argv[i++]));
last->next->prev = last;
last = last->next;
}
return head;
}
return NULL;
}
#include <stdio.h>
void print_stack(t_list *stack)
{
while (stack != NULL)
{
printf("%d\n", stack->data);
stack = stack->next;
}
}
void print_strack_rev(t_list *stack)
{
t_list *tmp;
tmp = stack;
while (tmp->next != NULL)
tmp = tmp->next;
while (tmp != NULL)
{
printf("%d\n", tmp->data);
tmp = tmp->prev;
}
}
int main(int argc, char **argv)
{
t_list *stack_a;
t_list *stack_b;
int *arr;
int *new_arr;
int i = 0;
stack_a = creat_stack(argc, argv);
arr = helper(stack_a);
new_arr = helper_big(stack_a);
//sort(&stack_a, &stack_b, 11);
sort_using_helper(&stack_a, &stack_b);
sor_last_chunk(&stack_a, &stack_b);
sor_full_stack(&stack_a, &stack_b);
// sort_using_helper2(&stack_b, &stack_a);
// sort_stack(&stack_b, &stack_a);
// repeat(&stack_a, &stack_b);
// printf("the smallest : %d \n", get_smaller((stack_a), 100));
// printf("the index : %d ", index_of(stack_a, get_smaller(stack_a, 100)));
// sort_parts(&stack_a, &stack_b);
// //sort_stack(&stack_a, &stack_b);
// printf("+++++++++\n");
// print_stack(stack_a);
// printf("\nhere we print the helpers: \n");
// while(i < 16)
// {
// printf("%d : %d\n", i+1, new_arr[i]);
// i++;
// }
// printf("1: %d\n", arr[0]);
// printf("2: %d\n", arr[1]);
// printf("3: %d\n", arr[2]);
// printf("4: %d\n", arr[3]);;
// printf("+++++++++\n");
// // print_stack(stack_b);
}