//数组的顺序存储表示
//杨鑫
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
#define OK 1
#define ERROR 0
#define UNDERFLOW 2
#define MAX_ARRAY_DIM 8
typedef int Status;
typedef int ElemType;
typedef struct {
ElemType *base; //数组的实体
int dim; //数组维数
int *bounds; //根据下文bound应该是bounds,数组各维的长度
int *constants; //数组映像函数常量的基址
}Array;
//数组初始化
Status InitArray(Array *A, int dim,...)
{
int elemtotal=1,i;
va_list ap;
if (dim < 1 || dim > MAX_ARRAY_DIM)
return ERROR;
A->dim = dim;
A->bounds = (int*)malloc(dim*sizeof(int));
if(!A->bounds)
return ERROR;
va_start(ap,dim);
for(i=0;i<dim;i++)
{
A->bounds[