数据结构最基础的问题!虚心受教了!
请高手详细的帮我讲解一下!谢谢!刚入门,觉得有点难理解!
数组的初始化的算法描述:
Status InitArray(Array &A,int dim,...)
{
if(dim<1 || dim>MAX_ARRAY_DIM) return ERROR;
A.dim = dim;
A.bounds = (int *)malloc(dim * sizeof(int));
if(!A.bounds) exit(OVERFLOW);
elemtotal = 1;
va_start(ap,dim);
for(i=0;i<dim;++i)
{
A.bounds[i] = va_arg(ap,int);
if(A.bounds[i]<0) return UNDERFLOW;
elemtotal * = A.bounds[i];
}
va_end(ap);
A.base = (ElemType *)malloc(elemtotal * sizeof(ElemType));
if(!A.base) exit(OVERFLOW);
A.constants = (int *)malloc(dim * sizeof(int));
if(i = dim-2; i>=0; --i)
A.constants[i] = A.bounds[i+1] * A.constants[i+1];
return OK;
}
[解决办法]
A.constants = (int *)malloc(dim * sizeof(int));
if(i = dim-2; i>=0; --i)
A.constants[i] = A.bounds[i+1] * A.constants[i+1];
怎么看到都不是if语句吧,之后,lz应该好好自己跑一边程序,这样更有好处!
[解决办法]
你要把array,va_start, va_arg这些的定义都贴上来吧