⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 习题-25.c

📁 含有大量数据结构的源代码 请大家漫漫品味
💻 C
字号:
//本程序只给出了算法思想
//读者可以自己完善本程序
void OEReform(DuLinkedList &L)
//按1,3,5,...4,2的顺序重排双向循环链表L中的所有结点
{
  	p=L.next;
  	while(p->next!=L&&p->next->next!=L)
  	{
    		p->next=p->next->next;
    		p=p->next;
  	} //此时p指向最后一个奇数结点
  	if(p->next==L) 
		p->next=L->pre->pre;
  	else 
		p->next=l->pre;
  	p=p->next; //此时p指向最后一个偶数结点
  	while(p->pre->pre!=L)
  	{
    		p->next=p->pre->pre;
    		p=p->next;
  	}
  	p->next=L; //按题目要求调整了next链的结构,此时pre链仍为原状
  	for(p=L;p->next!=L;p=p->next) 
		p->next->pre=p;
  	L->pre=p; //调整pre链的结构
}//OEReform

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -