动态链表插入排序如何插入了表尾
//作业的排序SeQueue& SeQueue::order()
{
JCB *t, *p, *pre, *old;
old = front->next; //将原链表头结点的下一个结点作为新结点
front->next = NULL; //截断旧头结点作为新链表头结点
while (old != NULL) //原表不为空时进行排序
{
t = old; //取原表头结点
old = old->next; //指向原表下一个结点
p = front; //新表移动指针
pre = front; //保存移动时的前驱
while (t->length >= p->length && p != NULL) //进行比较
{
pre = p;
p = p->next;
}
if (p == NULL) //插入到表尾
{
pre->next = t;
t->next = NULL;
}
else
{
if (p == pre) //插入到表头
{
t->next = p;
front = t;
}
else //插入到表中间
{
pre->next = t;
t->next = p;
}
}
return *this;
}
请大家分析一下当插入到表尾时有什么问题