I have a general question about searching inside a two-dimensional array. I'm working on a number search program that allows the user to enter a number to search in a grid of numbers. For example:
User wants to search: 234567
In a grid of:
232772725432
734234657337
272425672442
235533655737
252444474436
737533255325
656222376424
573233663633
325534255252
454456544442
237537362337
234562732722
The thing is I want to search backwards and diagonally also. I can easily come up with a sorting algorithm to find backwards and forwards vertically and horizontally but I have no idea how I can search diagonal. Would I use a while loop instead of a for loop so that I can increment each index of the two-dimensional array? That is what I have so far and it works sometimes but not all the time. Any suggestions would help. Thanks