logo
  • 教程列表
  • SO官方文檔
  • 氣泡排序
    • 氣泡排序
    • 在 CC 中實施
    • 在 Javascript 中實現
    • 在 C 中實施
    • 用 Java 實現
    • Python 實現
  1. StackOverflow 文件
  2. algorithm 教程
  3. 氣泡排序
  4. Python 實現

Python 實現

Created: November-22, 2018

#!/usr/bin/python

input_list = [10,1,2,11]

for i in range(len(input_list)):
  for j in range(i):
    if int(input_list[j]) > int(input_list[j+1]):
      input_list[j],input_list[j+1] = input_list[j+1],input_list[j]

print input_list
  • 用 Java 實現

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明