Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. def tri_bulle(tableau):
  2.     permutation = True
  3.     passage = 0
  4.     while permutation == True:
  5.         permutation = False
  6.         passage = passage + 1
  7.         for en_cours in range(0, len(tableau) - passage):
  8.             if tableau[en_cours] > tableau[en_cours + 1]:
  9.                 permutation = True
  10.                 # On echange les deux elements
  11.                 tableau[en_cours], tableau[en_cours + 1] = tableau[en_cours + 1],tableau[en_cours]
  12.     return tableau
  13.  
  14. print(tri_bulle([2, 5, 7, 1, 4, 8, 10, 6]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement