vc程序的的设计链表与链表的基本的的操作.pptVIP

  • 3
  • 0
  • 约1.29万字
  • 约 36页
  • 2017-03-28 发布于四川
  • 举报

vc程序的的设计链表与链表的基本的的操作.ppt

vc程序的的设计链表与链表的基本的的操作

templatetypename T NodeT* ListT::Find(T data){ NodeT *tempP=head-link; while(tempP!=NULLtempP-info!=data) tempP=tempP-link; return tempP; } //搜索成功返回该结点地址,不成功返回NULL templatetypename Tint ListT::Length( ){ NodeT* tempP=head-link; int count=0; while(tempP!=NULL){ tempP=tempP-link; count++;} return count; } Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. templatetypename Tvoid ListT::PrintList( ){ NodeT* tempP=head-link; while(tempP!=NULL){ couttempP-info\t; tempP=tempP-link; } coutendl; } templatetypename Tvoid ListT::InsertFront(NodeT *p){ p-link=head-link; head-link=p; if(tail==head) tail=p; } Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. templatetypename Tvoid ListT::InsertRear(NodeT *p){ p-link=tail-link; tail-link=p; tail=p; } templatetypename TNodeT* ListT::CreatNode(T data){ NodeT*tempP=new NodeT(data); return tempP; } Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. templatetypename Tvoid ListT::InsertOrder(NodeT *p){ NodeT *tempP=head-link, *tempQ=head; //tempQ指向tempP前面的一个结点 while(tempP!=NULL){ if(p-infotempP-info) break; //找第一个比插入结点大的结点,由tempP指向 tempQ=tempP; tempP=tempP-link; } tempQ-InsertAfter(p); //插在tempP指向结点之前,tempQ之后 if(tail==tempQ) tail=tempQ-link; } Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. templatetypename T NodeT* ListT::DeleteNode(NodeT* p){ NodeT* tempP=head; while(tempP-link!=NULLtempP-link!=p) tempP=tempP-link; if(tempP-link==tail) tail=tempP; return tempP-RemoveAfter( );

文档评论(0)

1亿VIP精品文档

相关文档