//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变成了尾节点
//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变成了尾节点