python 入门(1)if-for循环之冒泡排序
程序员文章站
2022-03-17 16:01:52
...
#coding:utf-8 import random print ("Python实现冒泡排序:") numlist = [] ele = None ranLen = 10 #生成随机数 for i in range(0,ranLen): ele = random.randint(0,100) numlist.append(ele) print ('随机%d个数集合:' %(ranLen)) print (numlist) #开始排序 for i in range(0,len(numlist)): for j in range(i+1,len(numlist)): if(numlist[i]>numlist[j]): temp = numlist[i] numlist[i] = numlist[j] numlist[j] = temp print ('冒泡后列表数组:') print (numlist)
上一篇: jquery表单插件form使用方法详解
下一篇: 真我Q3i对比OPPOA55哪个值得买?