-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_input2.c
85 lines (77 loc) · 1.78 KB
/
check_input2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_input2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: raqferre <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/17 17:53:17 by raqferre #+# #+# */
/* Updated: 2023/03/27 16:58:45 by raqferre ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int is_sorted(char *argv[])
{
int i;
i = 1;
while (argv[i] && argv[i +1])
{
if (ft_atoi(argv[i]) > ft_atoi(argv[i +1]))
return (0);
i++;
}
return (1);
}
int is_equal(char *argv[])
{
int i;
int j;
int temp;
i = 1;
while (argv[i])
{
temp = ft_atoi(argv[i]);
j = 1;
while (argv[j])
{
if (j == i)
j++;
else if (temp == ft_atoi(argv[j]))
return (1);
j++;
}
i++;
}
return (0);
}
int check_null(char *argv[])
{
int i;
i = 1;
while (argv[i])
{
if (ft_strlen(argv[i]) == 0)
return (1);
i++;
}
return (0);
}
int check_args(char *argv[])
{
if (ft_isnbr(argv) == 0)
return (1);
if (ft_isnbr(argv) == 1)
{
if (check_sign(argv) == 0)
return (1);
else if (is_max_min_int(argv) == 1)
return (1);
else if (is_equal(argv) == 1)
return (1);
else if (check_null(argv) == 1)
return (1);
else
return (0);
}
return (0);
}