Python冒泡算法
冒泡
def damo(sun):
for i in range(len(sun)-1):
for j in range(len(sun)-i-1):
if sun[j]> sun[j+1]:
sun[j], sun[j+1] = sun[j+1], sun[j]
return sun
冒泡
def damo(sun):
for i in range(len(sun)-1):
for j in range(len(sun)-i-1):
if sun[j]> sun[j+1]:
sun[j], sun[j+1] = sun[j+1], sun[j]
return sun