我对无限循环感到生气,你认为什么是合适的解决方案?在C++中对链表进行排序
void sorting() {
node * temphead = head;
node * tempnode = NULL;
for (int i=0; i<count; i++) {
for (int j=0; j<count-i; j++) {
if (temphead->data > temphead->next->data) {
tempnode = temphead;
temphead = temphead->next;
temphead->next = tempnode;
}
temphead=temphead->next;
count++;
}
}
}
我试图增量次数和使用前,用while-很多条件,后为没有结果环路
我明白了,这就是我真正需要的,但是当我在屏幕上仍然没有排序:(。谢谢你的建议。 –
嗯..我从内存,我会尽快调试它并重新发布工作版本 – sircodesalot
修正了与其交换节点本身,我只是交换了数据。 – sircodesalot