I am trying to create a 2D array of 3x3 using a single dimensional array starting from 1-9. 3 rows and 3 cols but the array is single dimensional. [1,2,3,4,5,6,7,8,9] but i am trying to represent it as :
[1,1 (1)] [1,2 (2)] [1,3 (3)]
[2,1 (4)] [2,2 (5)] [2,3 (6)]
[3,1 (7)] [3,2 (8)] [3,3 (9)]
The user only enters the rows and cols and the grid is fixed 3x3.
How can i calculate for example:
r2, c2 = 5?
if i do this r*c then i get the correct answer for 1*1, 1*2, 1*3, 2*3, 3*3 but not for others.
Thanks everyone
2007-01-10
05:03:37
·
3 answers
·
asked by
Manish
5