单链表逆置

王朝百科·作者佚名  2010-03-05  
宽屏版  字体: |||超大  

定义一个节点结构:

struct node

{

int date;//可能使用其它类型或结构

node *next;

};

假设你的链表已经存在,为L

node *curnode = L;//当前节点,指向开始

node *temp=curnode->next;//临时节点

curnode->next=NULL;

L=curnode;

//先将指针指向队尾

while(temp != NULL)

{

curnode=temp;

temp =curnode->next;

curnode->next=L;

L=curnode;

}

 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝百科 版权所有