数据结构与算法系列(1)-单链表类的实现(C++)(二)

2015-07-20 17:08:14 ? 作者: ? 浏览: 6
Sort(mid,end); } void LinkList::ASCMerge(LinkList& L) { this->SelfASOrder(); L.SelfASOrder(); node* q=(L.head)->next; node* p=head->next; int position=0; while((p!=NULL)&&(q!=NULL)) { if(q->data data) { InsertNode(position,q->data); q=q->next; position++; } else { p=p->next; position++; } } position=GetLength(); while(q!=NULL) { InsertNode(position,q->data); q=q->next; position++; } } void LinkList::DESCMerge(LinkList& L) { ASCMerge(L); Reverse(); } int main() { LinkList L(10); cout<<"Input the L1 List:"< >DataSearch; cout< >DataInsert; cout<<"Input the position to insert:"< >PosInsert; if(L.InsertNode(PosInsert,DataInsert)) { cout<<"Insert successfully! The new list is:"; L.PrintList(); } else cout<<"Insert Failed!"< >PosDel; if(L.DeleteNode(PosDel)) { cout<<"Delete successfully! The new list is:"; L.PrintList(); } else { cout<<"Delete Failed!"< 运行截图

?

-->

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: