posted 20 years ago
some thoughts for doing it quick and dirty...
i'd get the size, then create a 2-d array.
assuming you enter the data for the positions left to right, top to bottom,
you just read data for the array. the first row will have 2 (in [row,row] and [row,row+1]) elements (unless the array is 1x1), the last row will have 2 elements (in [row,row-1] and [row,row]), and every other row has 3 ([row,row-1], [row,row], [row,row+1]
so something like:
get size;
for (int row = 0; row < size; row++)
if row == 0
get one element [row,row]
if size > 1
get second element [row, row+1]
else if row == size - 1 //last row only has two datums in it
get 2 elements
else
get 3 elements
this might help. i'm sure there are better ways, but this might get you going....
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors