1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
bool knight(matrix<int>& board, int k, int i, int j) {
// result of this call
bool result = false;
// u, v are coordinates of the next move
int u, v, m; // m is the current attempted move;
// u and v are equivalent to the a and b discussed in specs.
// the board size
const int n = board.rows();
// use these offsets to determine the next move
// to (u,v) from (i,j)
static int dx[] = { 2, 1, -1, -2, -2, -1, 1, 2 }, dy[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
if (k == n*n) {
return true;
} else {
}
}
|