Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

选择排序python算法写错 #6

Open
thisisagan opened this issue Sep 8, 2022 · 4 comments
Open

选择排序python算法写错 #6

thisisagan opened this issue Sep 8, 2022 · 4 comments

Comments

@thisisagan
Copy link

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
Copy link
Author

issues貌似无法保持缩进

@wolverinn
Copy link
Owner

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

@thisisagan
Copy link
Author

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

@wolverinn
Copy link
Owner

确实是的,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants