二维阵列到一维阵列的转换

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了二维阵列到一维阵列的转换相关的知识,希望对你有一定的参考价值。

Convert a coordinate (x,y) into the index for a 1D array. For example, the coordinate (3,1) would be at array index 8 if there are 5 columns.

Assumption: Arrays start at 0.
  1. arrayPosition = (y * numberOfColumns) + x

以上是关于二维阵列到一维阵列的转换的主要内容,如果未能解决你的问题,请参考以下文章