struct stu *reserve(struct stu *head)
{
struct stu *p1,*p2,*p3;
p1=head;
p2=p1->next; // 这个结点为要移动的结点
while(p2)
{
p3=p2->next; //记录的为要移动的结点的下一个结点
p2->next=p1; //移动结点到最前
p1=p2; //移动的结点变为新表头
p2=p3; //下个结点变为要移动的结点
}
head->next=NULL; //移动完毕后head变为表尾,让它指向为空
head=p1;
return head;
}

浙公网安备 33010602011771号