#include <iostream>
#include <vector>
using namespace std;
int n = 5, m = 5;
vector<vector<int>> board = {
{0,0,0,0,0},
{0,1,1,1,0},
{0,1,0,1,0},
{0,1,1,1,0},
{0,0,0,0,0}
};
vector<vector<int>> visited(5, vector<int>(5, 0));
int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};
void dfs(int y, int x) {
visited[y][x] = 1;
for(int i = 0; i < 4; i++) {
int ny = y + dy[i];
int nx = x + dx[i];
cout << "검사: " << ny << " " << nx << "\n";
// 틀린 조건
if(nx >= 0 || ny >= 0 || nx < n || ny < m) {
cout << "continue 걸림\n";
continue;
}
if(visited[ny][nx]) continue;
dfs(ny, nx);
}
}
int main() {
dfs(0, 0);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: