def bubbleSort():

    for i in range(len(a)):
        for j in range(i+1,len(a)):
            if a[j]<a[i]:
                temp = a[j]
                a[j] = a[i]
                a[i] = temp
                
        print(a)
[1, 4, 6, 3, 2, 6, 8, 4]
[1, 2, 6, 4, 3, 6, 8, 4]
[1, 2, 3, 6, 4, 6, 8, 4]
[1, 2, 3, 4, 6, 6, 8, 4]
[1, 2, 3, 4, 4, 6, 8, 6]
[1, 2, 3, 4, 4, 6, 8, 6]
[1, 2, 3, 4, 4, 6, 6, 8]
[1, 2, 3, 4, 4, 6, 6, 8]

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2021-10-15
  • 2021-10-16
猜你喜欢
  • 2021-06-07
  • 2022-12-23
  • 2021-12-05
  • 2021-07-15
  • 2020-02-19
  • 2021-10-31
  • 2022-12-23
相关资源
相似解决方案