1
Reply

Searching in 2D Grid(c++)

Chetan Malhotra

Chetan Malhotra

Jun 23 2016 4:21 PM
398
Please take a look: http://www.geeksforgeeks.org/search-a-word-in-a-2d-grid-of-characters/
 
This is a C++ program that searches  a 2D grid for a particular word.
 
In, the code, there are two declarations:  
 
int x[]={-1,-1,-1,0,0,1,1,1};
int y[]={-1,0,1,-1,1,-1,0,1};
 
Can anyone please explain these?? The author says these are for searching in all the 8 directions. But i am not getting how?? 

Answers (1)