Is there a formula that can be used to get the index given the current column and row? The following is what I have so far. The problem is, however, that the code only works for the first row...
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
index = i * (columns - 1) + j;