Status DeleteAndInsertSub(LinkedList la
{
if(i<
p=la;k=
while(k<i){p=p
q=p;
while(k<=len){q=q
s=lb; k=
while(k<j){s=s
s
return OK;
}
解
Status DeleteAndInsertSub(LinkList &la
{
LinkList p
int k=
if(i<
// 在la表中查找第i個結點
p=la;
while(p&&k<i){
prev=p;
p=p
k++;
}
if(!p)return INFEASIBLE;
// 在la表中查找第i+len
q=p;k=
while(q&&k<len){
q=p
k++;
}
if(!q)return INFEASIBLE;
// 完成刪除
if(!prev) la=q
else prev
// 將從la中刪除的結點插入到lb中
if(j=
q
lb=p;
}
else{
s=lb;k=
while(s&&k<j
s=s
k++;
}
if(!s)return INFEASIBLE;
q
s
}
return OK;
}
解
Status ListDelete_L(LinkList &L
{
LinkList p
if(mink>maxk)return ERROR;
p=L;
prev=p;
p=p
while(p&&p
if(p
prev=p;
p=p
}
else{
prev
q=p;
p=p
free(q);
}
}
return OK;
}
解
void ListDelete_LSameNode(LinkList &L)
{
LinkList p
p=L;
prev=p;
p=p
while(p){
prev=p;
p=p
if(p&&p
prev
q=p;
p=p
free(q);
}
}
}
From:http://tw.wingwit.com/Article/program/sjjg/201311/23408.html