/
ft_print_linear.c
50 lines (45 loc) · 1.51 KB
/
ft_print_linear.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_linear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmanet <tmanet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/27 17:57:57 by tmanet #+# #+# */
/* Updated: 2016/05/05 11:17:26 by tmanet ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem.h"
static void ft_linear_cycle(t_anthill *ah, int ants)
{
t_list *elem;
int first;
first = 1;
elem = ah->bst_path;
while (elem)
{
if (ants - (*(t_room**)elem->content)->lgt > 0 &&
ants - (*(t_room**)elem->content)->lgt <= ah->ants)
{
if (!first)
ft_putchar(' ');
first = 0;
ft_putchar('L');
ft_putnbr(ants - (*(t_room**)elem->content)->lgt);
ft_putchar('-');
ft_putstr((*(t_room**)elem->content)->name);
}
elem = elem->next;
}
}
void ft_print_linear(t_anthill *ah)
{
int ants;
ants = 1;
while (ants <= ah->ants + ah->end->lgt)
{
ft_linear_cycle(ah, ants);
ft_putchar('\n');
ants++;
}
}