# coding=utf-8"""请输入10个数,并安从小到大的顺序排序"""num = [] def getTenNum(): for i in range(10): x = int(input("please input the num:")) num.append(x) def sortNum(n): length = len(n) for x in range(length): for y in range(x, length): if n[x] > n[y]: n[x], n[y] = n[y], n[x] if __name__=="__main__": getTenNum() sortNum(num) print(num) # 单纯的想练习一下冒泡排序,python中的列表排序可以直接依靠sort函数# 每天努力一点点
原文地址:https://www.cnblogs.com/walxt/p/11648049.html
时间: 2024-10-14 20:34:46