C语言,链表反转

倒序思路:依次把后面的节点移往头部。

struct
Node{ struct Node* next; int data; }; typedef struct Node NODE; NODE* invert_link_list2(NODE* head) { if(head == 0){ return 0; } NODE* xpre = head; NODE* x = head->next; for(; xpre->next != 0; x = xpre->next) { xpre->next = x->next; x->next = head; head = x; } return head; }

 

相关文章:

  • 2018-12-03
  • 2021-06-08
  • 2021-08-02
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-09-22
  • 2021-10-30
  • 2022-12-23
相关资源
相似解决方案