python selectsort

Posted tny_leyon

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python selectsort相关的知识,希望对你有一定的参考价值。

# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name: test
Description :
Author : Administrator
date: 2018/9/2 0002
-------------------------------------------------
"""

# the default max number

# for i in range(1, len(s)):
# index = 0
# j = None
# for j in range(1, len(s) - i):
# if s[j] > s[index]:
# # 找出当前最大值的位置
# index = j
# temp = s[len(s) - i]
# s[len(s) - i] = s[index]
# s[index] = temp
s = [9, 1, 3, 10, 5]
for i in range(len(s) - 1):
index = i
j = 1
# 从剩下的中选出最小
for j in range(i + 1, len(s)):
if s[j] < s[index]:
# 找出当前最小值的位置
index = j
# temp = s[i]
# s[i] = s[index]
# s[index] = temp
s[i], s[index] = s[index], s[i]
print(s)




























以上是关于python selectsort的主要内容,如果未能解决你的问题,请参考以下文章

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python

python初识