冒泡排序算法
冒泡排序算法
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=' ')
作者:楚千羽
出处:https://www.cnblogs.com/chuqianyu/
本文来自博客园,本文作者:楚千羽,转载请注明原文链接:https://www.cnblogs.com/chuqianyu/p/16247762.html
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利!