forked from levonka/fillit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfun.c
39 lines (34 loc) · 1.27 KB
/
fun.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fun.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yharwyn- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/12/21 08:41:30 by yharwyn- #+# #+# */
/* Updated: 2018/12/21 15:17:21 by yharwyn- ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
int find_sqr_ttr(int n)
{
int x = 1;
int decreased = 0;
int nx;
while (n) {
nx = (x + n / x) >> 1;
if (x == nx || (nx > x && decreased)) break;
decreased = nx < x;
x = nx;
}
return (x * x != n) ? ++x : x;
}
int find_quantity_ttr(int fd)
{
char *line;
int ttr;
ttr = 0;
while (get_next_line(fd, &line))
ft_strlen(line) <= 1 ? ttr += 1 : ttr;
return (ttr + 1);
}