Reversal of circular list

Reversal of circular list

topic

It is known that the head node pointer of the circular list with the head node is list. Please do not write an algorithm to reverse the direction of the link list.

Code

// 逆转链表的链接方向
void CHANGEOVER(LinkList list){   
	 LinkList p,q,r;    
	 p=list->link;    
	 q=list;    
	 while (p!=list)    {       
	 	r=q;       
	 	q=p;       
	 	p=p->link;       
	 	q->link=r;   
	  }    
	  list->link=q;
}

Guess you like

Origin blog.csdn.net/honeylife/article/details/99290829