void reverse(Node*& head) { if (!head) return; Node *p1, *p2, *p3; p1 = head; p2 = p1->next; p1->next = NULL; while (p2) { p3 = p2->next; p2->next = p1; p1 = p2; p2 = p3; } head = p1; }