def buss(num):
for j in xrange(len(num)-1,-1,-1):
for i in xrange(j):
if num[i]>num[i+1]:
num[i],num[i+1]=num[i+1],num[i]
print num
def main():
num=[12,23,43,5,3]
buss(num)
if __name__==‘__main__‘:
main()
时间: 2024-10-20 16:22:02
def buss(num):
for j in xrange(len(num)-1,-1,-1):
for i in xrange(j):
if num[i]>num[i+1]:
num[i],num[i+1]=num[i+1],num[i]
print num
def main():
num=[12,23,43,5,3]
buss(num)
if __name__==‘__main__‘:
main()