首页 > 编程语言 > 详细

数据结构-数组详解例子

时间:2016-01-07 14:50:40      阅读:361      评论:0      收藏:0      [点我收藏+]
struct Array
{
   ElemType *base;    /* 数组元素基址,由InitArray分配 */
   int dim;           /* 数组维数 */
   int *bounds;       /* 数组维界基址,由InitArray分配 */
   int *constants;    /* 数组映象函数常量基址,由InitArray分配 */
};
对于三维数组a[3][2][2]

base 是存储数组元素的指针,其指向的内存存储着: a[0][0][0] , a[0][0][1], a[0][1][0].........
dim  维数,存着: 3
bound 指向的内存存着: 3 2 2  //这个就是[3][2][2]
constants 指向的内存存着: 4 2 1  // contants[2]=1        contants[1]= 1 x 2 =2         contants[0]= 2 x 2 =4 

constants[]的计算.
constants[dim-1]=1;
for(i=dim-2; i>=0; i--)
  constants[i] = bound[i+1] * constants[i+1];

技术分享

 

数据结构-数组详解例子

原文:http://www.cnblogs.com/startnow/p/5109812.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!