//函数功能:把链表相邻元素反转 //输入参数:head:指向链表头结点 void reverse(Node* head){ if (head == NULL || head->next == NULL) return ; Node *pre = head, *cur = head->next, *next = NULL; while (cur != NULL && cur->next != NULL) { next = cur->next->next; pre->next = cur->next; cur->next->next = cur; cur->next = next; pre = cur; cur = next; } }