在2D数组中指定特定位置 [英] Specifying a particular position in a 2D array
本文介绍了在2D数组中指定特定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在2D数组中指定位置的方法是什么。我并不是说要通过下标获取值,而是以类似于一维数组的方式,在给定指针的情况下,可以使用 +
运算符并转到该位置。
What is the method for specifying a position in a 2D array. I do not mean getting the value through subscripting but in a way analogous to a 1D array where given a pointer it is possible to use a +
operator and go to that position.
例如,如果我有一些大小为4的数组 A
,则可以通过<$转到第三个元素c $ c> A + 2 。
For instance if I have some array A
of size 4, I can go to the third element by A + 2
.
拥有2D数组时该怎么办?
How would I do this when I have a 2D array?
推荐答案
其中 A
是数组, R
是行,而 C
是列。
Where A
is the array, R
is the row, and C
is the column.
*(A + R) + C
为您提供 A [R] [C]
这篇关于在2D数组中指定特定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文