单链表的逆置使用递归算法出现-842150451这个值 请求高手予以解决(单链表逆置)

单链表的逆置使用递归算法出现-842150451这个值 请求高手予以解决(单链表逆置)

首页维修大全综合更新时间:2025-10-15 14:25:40

单链表的逆置使用递归算法出现-842150451这个值 请求高手予以解决

node* reverse(node *head){if(head == NULL || head->next == NULL){return head;}node *cur = head;node *pre = NULL;node *tmp;while(cur->next){tmp = pre;pre = cur;cur = cur->next;pre->next = tmp; //操作pre的next逆转}cur->next = pre; //结束时,操作cur的next逆转return cur;}

大家还看了
也许喜欢
更多栏目

© 2021 3dmxku.com,All Rights Reserved.