Advertisement
Guest User

Untitled

a guest
Mar 25th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. #ordenação bolha
  2.  
  3. L = [5,3,1,2,4]
  4.  
  5. #L = [7,4,3,12,8]
  6.  
  7. x = 0
  8. ordenado = False
  9. while not ordenado:
  10.     ordenado = True
  11.     while x < (len(L) -1):
  12.      if L[x] > L[x+1]:
  13.          ordenado = False
  14.          L[x],L[x+1] = L[x+1],L[x]
  15.          
  16.  
  17. print(L)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement