-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkers.c
94 lines (84 loc) · 1.99 KB
/
checkers.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
87
88
89
90
91
92
93
94
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* checkers.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vsimeono <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/01 14:19:04 by vsimeono #+# #+# */
/* Updated: 2022/02/26 15:44:58 by vsimeono ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int more_than_int(int argc, char **argv)
{
while (--argc > 0)
if (ft_atoi(argv[argc]) < INT_MIN || ft_atoi(argv[argc]) > INT_MAX)
return (1);
return (0);
}
int has_duplicates(int argc, char **argv)
{
int i;
int j;
i = 1;
while (i < argc - 1)
{
j = i + 1;
while (j < argc)
{
if (ft_atoi(argv[i]) == ft_atoi(argv[j]))
return (1);
j++;
}
i++;
}
return (0);
}
int more_than_digits(int argc, char **argv)
{
int i;
while (--argc)
{
i = 0;
while (argv[argc][i])
{
if (ft_isdigit(argv[argc][i]) || argv[argc][i] == '-' || \
argv[argc][i] == '+')
i++;
else
return (1);
}
}
return (0);
}
int is_sorted(t_stack **stack)
{
t_stack *temp;
int i;
int count;
i = 1;
count = len_stack(stack);
temp = *stack;
while (temp->next != NULL)
{
if (i == temp->index)
i++;
temp = temp->next;
}
if (i == count)
return (1);
return (0);
}
void free_stack(t_stack **stack_a)
{
t_stack *tmp1;
t_stack *tmp2;
tmp1 = *stack_a;
while (tmp1 != NULL)
{
tmp2 = tmp1->next;
free(tmp1);
tmp1 = tmp2;
}
}