`
fuerbosi
  • 浏览: 465869 次
文章分类
社区版块
存档分类
最新评论

2.22-单链表就地逆转

 
阅读更多
typedef struct node
{
	int data;
	struct node*next;
}Linklist;
void Reverse(Linklist&L)
{
    Linklist *q=L.next,*p=L.next->next,*temp;
    q->next=NULL;
    while(p)
    {
        temp=p;
        p=p->next;
        temp->next=q;
        q=temp;
    }
    L.next=q;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics