-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.c
56 lines (49 loc) · 1.31 KB
/
helper.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* helper.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asayakov <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/26 16:35:42 by asayakov #+# #+# */
/* Updated: 2020/01/26 16:48:52 by asayakov ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
size_t ft_lstcount(t_list *lst)
{
size_t i;
i = 0;
while (i++)
{
if (lst != NULL)
break ;
lst = lst->next;
}
return (i);
}
int ft_sqrt(int x)
{
int l;
int r;
int m;
l = 1;
r = x;
while (l < r)
{
m = (l + r) / 2;
if (m * m < x)
l = m + 1;
else
r = m;
}
return (r);
}
int ft_min(int x, int y)
{
return ((x < y) ? x : y);
}
int ft_max(int x, int y)
{
return (x + y - ft_min(x, y));
}