|
-
Apr 21st, 2002, 12:59 AM
#1
Thread Starter
Lively Member
simple c++ problem plz help!
Hi All,
I'm working on a basic console program at the moment that uses a 2D array. I need to be able to go through the entire array CellGrid(which is 6* 6) and check all of it's surrounding values (all 8 of them) e.g
O X X
\ | /
O - O - X
/ | \
X O O
I need to then store the amount of surrounding X's in my surrounding integer then move onto the next cell until I have gone through the entire 2D array.
The problem occurs when I try to check all of the surrounding values in an array which is in the corner or on the edge.
i.e. CellGrid[0][0] is in the corner and thus I cannot check any of the values on the left because they aren't there!
Also in a value such as CellGrid[1][6] I cannot check any of the variables beyond the column 6 for the same obvious reason.
I need to somehow create an algorithm that knows how to check the surrounding cells/arrays rather than try to check all 8 positions because on the arrays in the corner or on the edges, it can't!
Any advice at all would be grealt appreciated.
Best Regards,
Smithy.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|