0
void insert(struct EMP* emp[])
{
struct EMP* previous = NULL;
struct EMP* current = top;
int i;
int j;
previous = current;
current = current -> next;
for(i = 1; i < numEmps; i++)
{
j = i;
while(j > 0 && previous -> id > current -> id)
{
previous = current;
j--;
}
current = current -> next;
}
}
因此,該參數是一個無序的數組,我想用一個插入排序來訂購吧。我遇到的問題是它需要鏈接列表。有什麼建議麼?上面是我現有的插入排序功能,不起作用。Ç - 插入排序用鏈表與無序排列
當然,它不起作用,當它仍然是NULL時使用'previous'。 – 2013-02-14 08:12:05
我認爲previous = current = top所以沒有問題。 – Elemental 2013-02-14 08:47:44
我在前面等於當前的地方添加了,然後當前等於下一個....它構建並運行,但沒有任何更改。有任何想法嗎? – 2013-02-14 08:49:54