-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush_ft_push_swap_sub_two.c
86 lines (77 loc) · 1.88 KB
/
push_ft_push_swap_sub_two.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_push_swap_sub_two.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tbui <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/06/14 13:20:52 by tbui #+# #+# */
/* Updated: 2016/06/14 13:22:22 by tbui ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_push_out(int *list_b)
{
free(list_b);
list_b = NULL;
}
int main_norm(int *list_a, int j)
{
if (check_for_dob(list_a, j) == 0)
return (err_out(list_a));
ft_push_swap(j, list_a);
ft_push_swap_end(list_a);
return (0);
}
char **get_input_arr(int *argc, char **argv)
{
int i;
int k;
char **res;
i = 0;
k = 1;
(*argc)--;
if (!(res = (char **)malloc(sizeof(char *) * (*argc))))
return (NULL);
while (i < (*argc))
{
res[i] = ft_strdup(argv[k]);
i++;
k++;
}
return (res);
}
int *inverse_table_arr_int(int argc, int *arr)
{
int i;
int k;
int *res;
i = 0;
k = argc - 1;
if (!(res = (int *)malloc(sizeof(int) * argc)))
return (NULL);
while (k >= 0)
{
res[i] = arr[k];
i++;
k--;
}
return (res);
}
char **inverse_table_arr(int argc, char **arr)
{
int i;
int k;
char **res;
i = 0;
k = argc - 1;
if (!(res = (char **)malloc(sizeof(char *) * argc)))
return (NULL);
while (k >= 0)
{
res[i] = ft_strdup(arr[k]);
i++;
k--;
}
return (res);
}