python基礎(chǔ)之冒泡排序

list_pratisce = [45,69,8,19,9]
n = len(list_pratisce)
for j in range(n):
    for i in range(n-1):
        if list_pratisce[i] > list_pratisce[i+1]:
            temp = list_pratisce[i]
            list_pratisce[i] = list_pratisce[i+1]
            list_pratisce[i+1] = temp
print(list_pratisce)
輸出結(jié)果:
[8, 9, 19, 45, 69]

文章標(biāo)題:python基礎(chǔ)之冒泡排序
分享鏈接:http://muchs.cn/article30/pdggso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、企業(yè)建站、軟件開發(fā)、搜索引擎優(yōu)化企業(yè)網(wǎng)站制作、Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司