开发者

how to represent a 2d matrix using a 1D array in c

in a two dimensional matrix in c how开发者_如何学Go do i know when the element is still on the current line and not on the second line of a matrix in a 1 dimensional array. aka how do i show that d is on the top line and d is one the next line in these two matrixs?

a b c

d e f

or

a b c d

e f g h


You can represent it in a 1D array, but you have to take care of the logic, which index belongs to which row and column.

e.g.: for a 4×4 matrix - index 0 to 3 would be on the first row. 4-7 on the second, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜