#!/usr/bin/env python
# -*- coding:utf-8 -*-
li = [33,2,10,1]
''' 过程
for i in range(len(li) - 1):
current = li[0]
next_value = li[1]
if li[i] > li[i+1]:
temp = li[i]
li[i] = li[i+1]
li[i+1] = temp
print(li)
for i in range(len(li) - 2):
current = li[0]
next_value = li[1]
if li[i] > li[i+1]:
temp = li[i]
li[i] = li[i+1]
li[i+1] = temp
print(li)
for i in range(len(li) - 3):
current = li[0]
next_value = li[1]
if li[i] > li[i+1]:
temp = li[i]
li[i] = li[i+1]
li[i+1] = temp
print(li)
'''
for j in range(1,len(li)): # 1,2,3
for i in range(len(li) - j): # 1,2,3
current = li[0]
next_value = li[1]
if li[i] > li[i + 1]:
temp = li[i]
li[i] = li[i + 1]
li[i + 1] = temp
print(li)
转载于:https://www.cnblogs.com/huangguabushihaogua/p/9694136.html