用户:
村民侦察兵查看:0 回复:0 评论:0 创建时间:2020-07-24T19:29:33
【作品展示】

【作品介绍】
本作品主要展示了冒泡算法是怎样实现的。
【作品源代码】
def bubbleSort(arr):
n = len(arr)
for i in range((n - 1)):
for j in range(0, ((n - i) - 1)):
liebiao[j] = int(liebiao[j])
liebiao[(j + 1)] = int(liebiao[(j + 1)])
if (liebiao[j] > liebiao[(j + 1)]):
zongjiang = liebiao[j]
liebiao[j] = liebiao[(j + 1)]
liebiao[(j + 1)] = zongjiang
lb = input('请输入一组数字(1,3,7,2)')
liebiao = lb.split(',')
bubbleSort(liebiao)
print(liebiao)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn