Python语言例题集(004)

#!/usr/bin/python3

#冒泡排序法

def bubbleSort(list):
index=len(list)-1
sorted=False
while not sorted:
sorted=True
for i in range(index):
if list[i]>list[i+1]:
sorted=False
list[i],list[i+1]=list[i+1],list[i]
index-=1

list=[65,55,45,35,25,15,10]
bubbleSort(list)
print(list)

相关推荐

  1. Python语言例题004

    2024-02-16 06:58:01       47 阅读
  2. Python语言例题002

    2024-02-16 06:58:01       50 阅读
  3. Python语言例题003

    2024-02-16 06:58:01       51 阅读
  4. Python语言例题006

    2024-02-16 06:58:01       48 阅读
  5. Python语言例题008

    2024-02-16 06:58:01       43 阅读
  6. Python语言例题(010)

    2024-02-16 06:58:01       31 阅读
  7. Python语言例题(013)

    2024-02-16 06:58:01       32 阅读
  8. Python语言例题(015)

    2024-02-16 06:58:01       29 阅读
  9. C语言例题6

    2024-02-16 06:58:01       53 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-16 06:58:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-16 06:58:01       101 阅读
  3. 在Django里面运行非项目文件

    2024-02-16 06:58:01       82 阅读
  4. Python语言-面向对象

    2024-02-16 06:58:01       91 阅读

热门阅读

  1. 寒假 14

    2024-02-16 06:58:01       50 阅读
  2. 相机—特点及区别

    2024-02-16 06:58:01       43 阅读
  3. uniapp实现手机横屏(方法二)

    2024-02-16 06:58:01       50 阅读
  4. 华为HCIE课堂笔记第十八章 SR技术

    2024-02-16 06:58:01       46 阅读
  5. 人机之间的不同交互

    2024-02-16 06:58:01       48 阅读
  6. 设计模式-装饰模式 Decorator

    2024-02-16 06:58:01       44 阅读