Home > Back-end >  Curriculum design of multidimensional arrays
Curriculum design of multidimensional arrays

Time:01-16

Problem description]
Design and simulation implementation integer multidimensional array type,
[basic requirements]
While programming language such as C already provides a multi-dimensional array, but in some cases, define the multidimensional arrays are useful, according to user's requirements by design and simulation of multi-dimensional array type, can be deep understanding and mastering the multidimensional arrays, integer multidimensional arrays should have the following basic functions:
(1) define the type of integer multidimensional array, each dimension of subscript consecutive integers is arbitrary integer beginning;
(2) the index variable assignment, execute the subscript range check;
(3) the same type array assignment;
(4) the subarray assignment, for example, a [1.. n]=a [2.. n + 1);
A [2.. 4] [3... 5)=b [3] 1.. [2.. 4];
(5) to determine the size of the array,
[test data]
Designated by the readers,
[implementation tips]
All the basic functions can be implemented respectively function was used to simulate and should reflect on the form and function parameters setting, define integer multidimensional array type, the type of the definition of information can be stored in the following types of records:
# define MaxDim 5
Typedef struct
Int dim,
BoundPtr the lower and Upper;
ConstPtr constants;
) NArray, * NarrayPtr;

Integer storage structure of the multidimensional array variable type can be defined as:
Typedef struct {
ElemType * elem;
Int num.
NArrayType TypeRecord;
} NArrayType;
Have bosses teach small white
  • Related