-
Notifications
You must be signed in to change notification settings - Fork 0
/
dfs.c
executable file
·41 lines (38 loc) · 1.49 KB
/
dfs.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* dfs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ioleksiu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/15 20:04:43 by ioleksiu #+# #+# */
/* Updated: 2017/08/15 20:04:45 by ioleksiu ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
void dfs(t_lemin *lem)
{
int ochered[lem->room_num + 1];
if (last_v(lem) == lem->room_num - 1)
{
lem->way_num++;
add_way(lem);
del_last_visited(lem);
del_q_static(ochered, lem->room_num);
return ;
}
add_q_static(lem, ochered);
while (ochered[0] != -1 && !(ochered[0] == 0 && ochered[1] == -1))
{
if (last_q_static(ochered) != -1
&& !is_visited(lem, last_q_static(ochered)))
{
add_visited_static(ochered, lem);
del_q_static(ochered, lem->room_num);
dfs(lem);
}
if (is_visited(lem, last_q_static(ochered)))
del_q_static(ochered, lem->room_num);
}
del_last_visited(lem);
}