python实现插入排序,python实现排序, #coding:
文章由Byrx.net分享于2019-03-23 05:03:49
python实现插入排序,python实现排序, #coding:
#coding: UTF-8 def arrage(temp_list): num = len(temp_list) for i in range(1,num): for j in range(i): if temp_list[i] >= temp_list[j] and j == (i-1): break elif temp_list[i] <= temp_list[j] and j == 0: temp_list.insert(0,temp_list.pop(i)) elif temp_list[i] <= temp_list[j+1] and temp_list[i] >= temp_list[j]: temp_list.insert((j+1),temp_list.pop(i)) def main(): temp_list = [2,3,6,5,15,4,7,6,34,23,1,24] arrage(temp_list) print temp_list main()
评论关闭