Iridescent icon indicating copy to clipboard operation
Iridescent copied to clipboard

选择排序python算法写错

Open thisisagan opened this issue 3 years ago • 4 comments

def select_sort(lst): if not lst: return [] for i in range(len(lst) - 1): smallest = i for j in range(i, len(lst)): if lst[j] < lst[smallest]: smallest = j lst[i], lst[smallest] = lst[smallest], lst[i] #已更正 return lst

thisisagan avatar Sep 08 '22 07:09 thisisagan

issues貌似无法保持缩进

thisisagan avatar Sep 08 '22 07:09 thisisagan

你指的是algorithms.md里的选择排序写错了吗?我对比了一下,好像没看出你的更正版本和现在的版本的区别

wolverinn avatar Sep 09 '22 11:09 wolverinn

你指的是algorithms.md里的选择排序写错了吗?我对比了一下,好像没看出你的更正版本和现在的版本的区别 lst[i], lst[smallest] = lst[smallest], lst[i] 该句应该放在i循环内吧?

thisisagan avatar Sep 11 '22 04:09 thisisagan

确实是的,谢谢

wolverinn avatar Sep 13 '22 00:09 wolverinn