Advertisement
LinuxAIO

Ejercicio 6.14

Mar 27th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. L = [1, 2, 3, 4, 5]
  2. fin = 5
  3. while fin > 1:
  4.     cambio = False
  5.     x = 0
  6.     while x < (fin - 1):
  7.         if L[x] > L[x+1]:
  8.             cambio = True
  9.             #Variable Auxiliar
  10.             temp = L[x]
  11.             L[x] = L[x+1]
  12.             L[x+1] = temp
  13.         x+=1
  14.     if not cambio:
  15.         break
  16.     fin -= 1
  17. for e in L:
  18.     print(e)
  19. ## En este caso todo va a ser falso ya que la Lista esta ordenada
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement