题解
单链表的选择排序
http://www.nowcoder.com/questionTerminal/78f83c3f12d2464591ebc5a73183db35
void swap(list_node * a, list_node * b) { int tmp = a->val; a->val = b->val; b->val = tmp; } list_node * selection_sort(list_node * head) { //////在下面完成代码 if(head == nullptr || head->next == nullptr) return head; for(list_node* i=head; i != nullptr; i = i->next) { for(list_node* j=i->next; j != nullptr; j = j->next) { if(j->val < i->val) swap(i,j); } } return head; }