单链表的反转核心代码

1. 数据结构和算法一定要画图, 要一步一步进行思考,核心代码实现如下

Node prev = null;
while(head.next != null)
{
    Node temp = head;
    head->next = prev;
    prev = head;
    head = temp->next;
}

猜你喜欢

转载自blog.csdn.net/wangping623/article/details/93723176
今日推荐