1--
struct Node *Reverse(struct Node *head) //反转链表
{
struct Node *current,*prev,*tmp;
current = head;
prev= current->next;
while (prev != NULL)
{
tmp = prev->next;
prev->next = current;
current = prev;
prev = tmp;
}
head->next = NULL;
head = current;
return head;
}
2--
void InsertAfter(Node *ptr,Node *nextptr)
{
nextptr->next = ptr->next;
ptr->next = nextptr;
}
Node *DeleteAfter(Node *p)
{
Node *tmp = p->next;
if (tmp != NULL)
{
p->next = tmp->next;
}
return tmp;
}
void Revert(Node *head)
{
Node *rear=head,*del;
if(head->next != NULL)
rear= head->next;
while (rear->next != NULL)
{
del =DeleteAfter(rear);
InsertAfter(head,del);
}
}