Given the matrix n * n and the value of k, how to find all the neighbors for each element? for example: in a 4*4 matrix, with k=2 for example, the matrix:
[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
where these values ββare location indices, the neighbors for 1 are 1,2,3,5,6,9 . The values 3,6 and 9 appear only because k = 2 and would not be there if k was = 1.
similarly, neighbors of 6 will be 1 2 3 5 6 7 8 9 10 11 and 14
Could you help me write c code to implement this in C ++.
This is von Neumann's neighborhood problem, please, you can implement it in C ++. thank
c ++ algorithm matrix nearest-neighbor
koder May 16 '11 at 7:10 2011-05-16 07:10
source share