-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsapin_sapin.c
50 lines (44 loc) · 1.17 KB
/
sapin_sapin.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
#include "sapin.h"
void sapin(int size)
{
int counter_para = 1;
int counter_line;
int nb_line;
int nb_carac_line = get_last_nb_etoile(size);
int nb_etoile;
int nb_pipe = (size % 2 == 0) ? (size + 1) : size;
/* gestion erreur argument input */
if (size == 0)
return;
if (size <= 0)
{
my_putstr("Argument needs to be a positive number.\n");
return;
}
/* print du corps */
while (counter_para <= size)
{
counter_line = 1;
nb_line = counter_para + 3;
while (counter_line <= nb_line)
{
nb_etoile = get_nb_etoile(counter_para, counter_line);
my_print_carac(' ', get_nb_space(nb_carac_line, nb_etoile) / 2);
my_print_carac('*', get_nb_etoile(counter_para, counter_line));
my_print_carac(' ', get_nb_space(nb_carac_line, nb_etoile) / 2);
my_putstr("\n");
counter_line++;
}
counter_para++;
}
/* print du tronc */
counter_line = 0;
while (counter_line < size)
{
my_print_carac(' ', get_nb_space(nb_carac_line, nb_pipe) / 2);
my_print_carac('|', nb_pipe);
my_print_carac(' ', get_nb_space(nb_carac_line, nb_pipe) / 2);
my_putstr("\n");
counter_line++;
}
}