标签:
本文主要是实现:python中的冒泡排序
代码:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# author by lh
li = [33, 2, 10, 1]
for j in range(1,len(li)):
for i in range(len(li) - j):
if li[i] > li[i+1]:
temp = li[i]
li[i] = li[i+1]
li[i+1] = temp
print li
运行结果:
标签:
原文地址:http://www.cnblogs.com/pythonlh/p/5760089.html