随笔分类 - 数据结构
摘要:① 搜索最小值 python的min函数返回列表中的最小项 1 def indexOfMin(lyst): 2 minIndex = 0 3 currentIndex = 1 4 while currentIndex < len(lyst): 5 if lyst[currentIndex] < ly
阅读全文
posted @ 2023-12-06 17:20
木屐呀
摘要:使用swap函数来交换列表中的两项的位置 1 def swap(lyst,i,j): 2 '''交换列表中两项的位置''' 3 temp = lyst[i] 4 lyst[i] = lyst[j] 5 lyst[j] = temp ① 选择排序 处于列表第一项,先找到最小项的位置,如果该位置不是列表
阅读全文
posted @ 2023-12-06 17:19
木屐呀

浙公网安备 33010602011771号