#include using namespace std; struct cell { int x, y; int dis; cell() {} cell(int x, int y, int dis) : x(x), y(y), dis(dis) {} }; bool isInside(int x, int y, int N) { if (x >= 1 && x <= N && y >= 1 && y <= N) return true; return false; } void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. int dx[] = { -1, 1, 2, 1,-1, 2}; int dy[] = { -2, -2,0, 2, 2,0}; queue q; q.push(cell(i_start,j_start, 0)); cell t; int x, y; bool visit[n+ 1][n + 1]; // make all cell unvisited for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) visit[i][j] = false; visit[i_start][j_start] = true; while (!q.empty()) { t = q.front(); q.pop(); visit[t.x][t.y] = true; // if current cell is equal to target cell, // return its distance if (t.x == i_end && t.y == j_end){ cout<> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }