习题3.3---只通过调整指针来达到相邻结点交换的过程

//单链表
void
ExchangeNear( List L, Position PosBefoP )
{
    Position PosL,PosR;
    PosL = PosBefoP->Next;
    PosR = PosL->Next;
    
    PosL->Next = PosR->Next;
    PosR->Next = PosL;
    PosBefoP->Next = PosR;
}
//双链表
void
ExchangeNear( Position PosBefoP, List L )
{
    Position P,PosAfteP;
    P = PosBefoP->Next;
    PosAfteP = P->Next;
    
    P->Next = PosAfteP->Next;
    P->front = PosAfteP;
    
    PosAfteP->Next = P;
    PosAfteP->front = PosBefoP;
    
    PosBefoP->Next = PosAfteP;
}
View Code

 

posted @ 2015-07-05 00:22  Gabyler  阅读(175)  评论(0编辑  收藏  举报