冒泡排序算法
作者:互联网
冒泡排序算法
class Solution():
def maopao(self, arr: list) -> list:
N = len(arr)
for i in range(N-1,0,-1):
for j in range(i):
temp = 0
if arr[j] > arr[j+1]:
temp = arr[j]
arr[j] = arr[j+1]
arr[j+1] = temp
return arr
if __name__ == '__main__':
arr = list(map(int,input().strip().split()))
s = Solution()
kk = s.maopao(arr)
N = len(kk)
for i in range(N):
print(kk[i],end=' ')
标签:__,arr,temp,kk,list,range,冒泡排序,算法 来源: https://www.cnblogs.com/chuqianyu/p/16247762.html