#include #include #include #include #include #include #include //UL, UR, R, LR, LL, L static int y[6] = {-1, +1, +2, +1, -1, -2}; static int x[6] = {-2, -2, 0, +2, +2, 0}; int vis[201][201]; int min = 2000; int path[2000]; int isSafe(int nx, int ny, int n) { return ((nx>=0 && nx=0 &&ny min) return 0; if (cx == dx && cy == dy) { if (min > cval) { min = cval; return 1; } return 0; } bool is_safe = false; vis[cx][cy] = cval; for(int i = 0;i<6;i++){ int nx = cx + x[i]; int ny = cy + y[i]; if(isSafe(nx, ny, n) && vis[nx][ny] > cval) { if(printUtil(n, nx, ny, dx, dy, cval+1)) { is_safe = true; path[cval] = i; } } } return is_safe ? 1 : 0; } 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. for(int i = 0; i