Answer the question
In order to leave comments, you need to log in
Knight's move in C++?
I don't know where to start writing a "knight's move" program. The matrix is 3 by 3, the elements are numbered from 1 to 9, at the end you need to indicate which numbers the horse went to,. At first I thought that the sum i+j should always be equal in the course of 1->2->3->(6) and so on with all the variations. Then I thought, even and not even. Added the values themselves and also checked for parity. There is a pattern between sums and parity, so what, I can't use it. I can’t figure out how to get to a cell/element that is 3 steps forward/backward and 1 to the right/left (to get to the original element, you need to overcome 6 elements horizontally/vertically). What to do? How does it work with arrays?
for (i=0 i<3 i++){
for (j=0 j<3 j++){
n++;
if(n==6)
mmr += a[i][j];
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question