Question: For this program, we are going to pretend that C++ has no built-in facility for two- dimensional arrays. It is possible to emulate them yourself
For this program, we are going to pretend that C++ has no built-in facility for two- dimensional arrays. It is possible to emulate them yourself with wrap one dimensional array. The basic idea is shown below. per functions around a Consider the following two-dimensional array: int matrix[2][3]; matrix[01[1 matrix[1]1 matrix e12 matrix 11121 matrix(10 The two-dimensional array can be mapped to storage in a one dimensional array where each row is stored in consecutive memory locations (your compiler actually does something very similar to map two dimensional arrays to memory). int matrix1D[6]; matrixiD matrixiD Toreoi1 matrixiDmatrixiD matrixiD matrix1D | [0] [0] 1 [0] [1] | [0] [2] [1] [0] [1] [1] | [1][2] | Here, the mapping is as follows: matrix[e][0] would be stored in matrixD[o] matrix[01[1] would be stored in matrixiD[1] matrix[e][2] would be stored in matrixiD[2] matrix[1][e] would be stored in matrixiD[3] matrix[1][1] would be stored in matrix1D[4] matrix[1][2] would be stored in matrixiD[5]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
