Status PriorElem(SqList L, ElemType cur_e, ElemType* pre_e)
{ /* 初始条件:顺序线性表L已存在 */
/* 操作结果:若cur_e是L的数据元素,且不是第一个,则用pre_e返回它的前驱, */
/* 否则操作失败,pre_e无定义 */
int i = 2;
ElemType* p = L.elem + 1;
while(i<=L.length && *p!=cur_e)
{
p++;
i++;
}
if(i>L.length)
{
return INFEASIBLE;
}
else
{
*pre_e = *--p;
return OK;
}
}