-2
这是我的code.I想知道为什么它不起作用。C++按升序排序链接列表
sll_node *sortList(sll_node *head)
{
int temp=head->value;
if(head!=NULL||temp>head->next->value)
{
head->value=head->next->value;
head->next->value=temp;
}
else
{
sortList(head->next);
sortList(head->next->next);
sortList(head->next);
}
return head;
}
你可以请指定你的意思是**“它不工作。”** –
请使用调试器。上述代码中的问题不是太深奥。运行一个小列表,并在其上运行'sortList's操作会显示答案。 – Pradhan
或者刚开始添加打印语句,这应该足以解决这个问题。在你已经解除引用'head'之后,你正在检查'NULL' *。 – Praetorian