Skip to content

Commit e757318

Browse files
committed
C++ step by step
1 parent 5a4ebad commit e757318

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

maze.asm

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
size: .word 5 #linhas (size) => x
1313
.word 5 #colunas 4(size) => y
1414

15-
step: .byte 1 #passo-a-passo: -1: não mostra, 1: mostra
15+
step: .byte -1 #passo-a-passo: -1: não mostra, 1: mostra
1616

1717
elem: .word 25 #elementos na matriz
1818

maze.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ int pos[4][2] = {{0, -1},
1818
{-1, 0},
1919
{ 1, 0}};
2020

21+
int step = -1;
22+
2123
void printmaze() {
2224
for (int i = 0; i < size; ++i) {
2325
for (int j = 0; j < size; ++j) {
@@ -37,8 +39,10 @@ bool dfs(int x, int y) {
3739
if (maze[novox][novoy] == 'X') return true;
3840
if (maze[novox][novoy] == '_') {
3941
maze[novox][novoy] = 'o';
42+
if (step < 0) printmaze();
4043
if (dfs(novox, novoy)) return true;
4144
maze[novox][novoy] = '_';
45+
if (step < 0) printmaze();
4246
}
4347
}
4448
}

0 commit comments

Comments
 (0)