nickkkkkkk

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
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;
}

 

posted on 2018-08-27 11:36  nickkkkkkk  阅读(109)  评论(0)    收藏  举报