我不知道這是否是基本的,但我只知道如何按升序排序。如何按降序對鏈表進行排序?
system("cls");
if (headptr != (struct online*)NULL)
{
currentptr = headptr;
for(; currentptr->ptrnext != NULL; currentptr = currentptr->ptrnext)
{
for(newptr = currentptr->ptrnext; newptr != (struct online*)NULL; newptr = newptr->ptrnext)
{
if(currentptr->score > newptr->score)
{
int temp = currentptr->score;
currentptr->score = newptr->score;
newptr->score = temp;
}
}
}
}
這部分負責對訂單作出決定?什麼是補充操作? –
重複了很多問題...你嘗試過: http://stackoverflow.com/questions/5526750/linked-list-sorting-in-c http://stackoverflow.com/questions/11813696/sorting -a-linked-list-in-c 甚至簡單的谷歌? 如果您可以按升序對其進行排序,則可以通過顛倒比較來顛倒順序,就像這裏提到的答案一樣。 –