线性表的顺序存储结构-添加元素
//添加元素
public bool Add(T element)
{
    if (this._currentLength < this._maxLength)
    {
        this._data[this._currentLength] = element;
        this._currentLength++;
        return true;
    }

    Console.WriteLine("元素已满!!");
    return false;
}


在判断不超过数组大小的情况下,就可以直接在数组(数据域)末尾元素后面位置添加上元素

长度+1


首页 我的博客
粤ICP备17103704号