“Ordem ascendente em Python usando o tipo de bolha” Respostas de código

Ordem ascendente em Python usando o tipo de bolha

5
4
5
5
Lively Lizard

Ordem ascendente em Python usando o tipo de bolha

def bubble_sort(num):  
    for i in range(0,len(num)-1):  
        for j in range(len(num)-1):  
            if(num[j]>num[j+1]):  
                temp = num[j]  
                num[j] = num[j+1]  
                num[j+1] = temp  
    return num  
  
num = [2, 1, 4, 5, 7]  
print("The unsorted number: ", num)  
print("The sorted number: ", bubble_sort(num))  
krisha may bermillo

Respostas semelhantes a “Ordem ascendente em Python usando o tipo de bolha”

Perguntas semelhantes a “Ordem ascendente em Python usando o tipo de bolha”

Mais respostas relacionadas para “Ordem ascendente em Python usando o tipo de bolha” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código