I have a 1d array of ints ( int boardCells[49]; ) which models cells on a game board(see below picture).

**My Problem:**

Given the index of an element in boardCells, I need to find out what column that cell is in & what row that cell is in.

*I know that I could just use a 2d array & it would be alot easier but I am rewritting a large program & I will have to go through everything to if I change from a 1d to 2d array.*

So I am trying to use some maths(not my strong point)

**to find the column & row associated with a cell index**. In my picture below the cell boardCells[ 10 ] would be selected, but what formula can I use to find out what column & row boardCells[ 10 ] is in?

**Also my picture is not that correct because in the program the number of columns always equals the number of rows(whereas in the picture there are 7 columns & 4 rows) but the picture is just an example.**

Would maybe some formula like this work, (again math is not my strong point):

int column = selectedCellIndex % totalNumOfCells;

int row = selectedCellIndex % totalNumOfCells;

This post has been edited by **gretty**: 22 September 2010 - 11:57 PM