zoukankan      html  css  js  c++  java
  • 数据结构-数组详解例子

    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];

  • 相关阅读:
    Chisel3
    Chisel3
    Chisel3
    Chisel3
    Chisel3
    Chisel3
    Chisel3
    Chisel3
    Chisel3
    UVa 12716 (GCD == XOR) GCD XOR
  • 原文地址:https://www.cnblogs.com/startnow/p/5109812.html
Copyright © 2011-2022 走看看