dwlakes

Untitled

Jun 13th, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. array = [2, 8, 5, 3, 9, 4, 1]
  2.  
  3. n = len(array)
  4.  
  5. i = 0
  6. j = 0
  7.  
  8. for i in range(n - 1):
  9. for j in range(n - 1):
  10. if array[j] > array[j + 1]:
  11. temp = array[j]
  12. array[j] = array[j + 1]
  13. array[j + 1] = temp
  14.  
  15. print(array)
  16. print(i, j)
  17.  
Advertisement
Add Comment
Please, Sign In to add comment