linelist.cpp
来自「数据结构算法Visual C++6.0程序集的源代码」· C++ 代码 · 共 25 行
CPP
25 行
//线性表的操作linelist.cpp
#include "linelist.h"
void List::init(List *L)
{L->elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L->elem) exit(OVERFLOW);
L->length=0;
L->listsize=LIST_INIT_SIZE;
}
int List::ListLength()
{return length;}
ElemType List::GetElem(int i,ElemType *e)
{*e=elem[i];return *e;}
bool List::ListInsert(int i,ElemType e)
{ ElemType *p,*q;
if (i<0||i>length) return false;
q=&elem[i];
for(p=&elem[length];p>=q;--p)
*(p+1)=*p;
*q=e;
++length;
return true;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?