View this page "Problema 3: Algoritmo de Ordenação"

3 views
Skip to first unread message

Toscano

unread,
Jan 29, 2010, 11:36:14 AM1/29/10
to Python: rumo a janela

Click on http://groups.google.com/group/python-rumo-a-janela/web/problema-3-algoritmo-de-ordenao
- or copy & paste it into your browser's address bar if that doesn't
work.

Toscano

unread,
Jan 29, 2010, 12:08:18 PM1/29/10
to Python: rumo a janela
Esse algoritmo é bastante simples, mas extremamente custoso!

#Autor Rafael Toscano

def Pysort():
quantidade = int(raw_input())
lista = []
temp = 0
a = 0
b = 0
for i in range(quantidade):
temp = int(raw_input())
lista.append(temp)

for j in range(len(lista)):
for k in range(j+1,len(lista)):
if(lista[j]>lista[k]):
a = lista[j]
b = lista[k]
lista[k] = a
lista[j] = b
print lista

Pysort()

Devemos buscar escrever algo semelhante ao mergesort para zelar pela
eficiência

Reply all
Reply to author
Forward
0 new messages