/
ft_checks_p9.c
111 lines (100 loc) · 2.1 KB
/
ft_checks_p9.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_checks_p9.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: syusof <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/05/05 14:29:01 by syusof #+# #+# */
/* Updated: 2016/05/05 14:32:31 by syusof ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_checks21b2a(t_numb *e)
{
int cnt;
cnt = 0;
e->g = ft_strlen(e->s);
if (e->indzero == 0)
{
while (e->w - e->g > 0)
{
cnt++;
ft_putchar(' ');
(e->w)--;
}
}
else
{
while (e->w - e->g > 0)
{
cnt++;
ft_putchar('0');
(e->w)--;
}
}
return (cnt);
}
int ft_checks22(t_numb *e)
{
int cnt;
cnt = 0;
if (e->pr > 6)
e->pr = 6;
if (e->w == 0 && e->pr == 0 && e->indpr == 0)
cnt = cnt + ft_checks22a(e);
else if (e->indpr == 1)
cnt = cnt + ft_checks22b(e);
else if (e->indpr == 0)
cnt = cnt + ft_checks22c(e);
return (cnt);
}
int ft_checks22a(void)
{
int cnt;
int i;
char sn[7];
ft_fullsn(sn);
cnt = 0;
i = 0;
while (i < 6)
{
ft_putchar(sn[i]);
cnt++;
i++;
}
return (cnt);
}
int ft_checks22b(t_numb *e)
{
int cnt;
cnt = 0;
if (e->indminus == 1)
cnt = cnt + ft_checks22b1(e);
else if (e->indminus == 0)
cnt = cnt + ft_checks22b2(e);
return (cnt);
}
int ft_checks22b1(t_numb *e)
{
int cnt;
int i;
char sn[7];
ft_fullsn(sn);
cnt = 0;
if (e->pr > 0)
{
e->prbegi = e->pr;
i = 0;
while (i < 6 && e->pr > 0)
{
ft_putchar(sn[i]);
cnt++;
i++;
(e->pr)--;
}
e->pr = e->prbegi;
}
cnt = cnt + ft_checks22b1a(e);
return (cnt);
}