Yahoo Answers is shutting down on 4 May 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Help with Arrays?

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

3 Answers

Relevance
Still have questions? Get answers by asking now.