chen-w
8/11/2017 - 4:41 AM

2d_to_1d

2d_to_1d

Way to tranfer 2d matrix to 1d array.

e.g.
matrix[][]
row count = m
col count = n

for matrix[x][y], its 1d version is x*n+y

for 1d array element at position a.
its location in matrix is:
x = a / n
y = a % n