//head为原始链表的头节点地址
listNode *buf = head;
listNode *pre = buf;
while(head->next != NULL)
{

  buf = head->next;
  head->next = buf->next;
  buf->next = pre;
  pre = buf;

}

//该段代码结束后,buf变成了头节点,head变成了尾节点

相关文章:

  • 2021-08-20
  • 2022-02-09
  • 2021-07-29
  • 2021-06-23
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
猜你喜欢
  • 2022-03-08
  • 2021-11-05
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
相关资源
相似解决方案