-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevals.c
68 lines (61 loc) · 1.55 KB
/
evals.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* evals.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ozahir <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/03 22:27:36 by ozahir #+# #+# */
/* Updated: 2022/06/09 15:51:46 by ozahir ### ########.fr */
/* */
/* ************************************************************************** */
#include "philosophers.h"
static int is_num(char *number)
{
int i;
int len;
len = ft_strlen(number);
i = 0;
if (len == 1 && number[0] == '0')
return (0);
while (i < len)
{
if (number[i] == '+' || (number[i] <= '9' && number[i] >= '0'))
i++;
else
return (0);
}
return (1);
}
int is_right(char *number)
{
int i;
int j;
i = 0;
j = 0;
while (number[i])
{
if (number[i] == '+')
j++;
i++;
}
if (j == 0)
return (1);
else if (j == 1 && number[0] == '+')
return (1);
return (0);
}
int input_eval(char **av)
{
int i;
i = 0;
while (av[i])
{
if (is_num(av[i]) == 0)
return (0);
if (is_right(av[i]) == 0)
return (0);
i++;
}
return (1);
}