python: 选择排序

来源:互联网 发布:windows错误报告 进程 编辑:程序博客网 时间:2024/06/06 09:18

python: 选择排序

标签:python 选择排序

by 小威威


下面是我用python写的选择排序。

#!/usr/bin/python3# Filename: selectionsort.pylist = input().split()list = [int(i) for i in list]index = 0for i in range(len(list)-1, 0, -1):    for j in range(0, i+1):        if list[index] < list[j]:            index = j    temp = list[index]    list[index] = list[i]    list[i] = temp    index = 0print (list)
0 0