/**
*Node为节点类型,root保存的是第一个节点的地址
*/
Node * reverse_linklist(Node *root) //传入根节点
{
Node *current;
Node *pnext;
/*遍历开始current记录当前位置,pnext记录下一位置*/
current = root;
pnext = root->next;
/*********判断链表是否为空*********/
if(root == NULL)
{
fprintf(stderr,"the link is empty!\n");
return NULL;
}
current->next = NULL; /*将第一个节点指针域置为空*/
/***************实现反转*********************/
while(pnext != NULL)
{
root = pnext->next;//跟新root为pnext的下一节点
pnext->next = current;//跟新pnext->为它的上一节点即current
current = pnext;
pnext = root;
}
root = current;
return root;
}