diff bubblesort/bubblesort.py @ 0:dcd610585610

INIT
author prymula <prymula76@outlook.com>
date Thu, 21 Sep 2023 22:32:14 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bubblesort/bubblesort.py	Thu Sep 21 22:32:14 2023 +0200
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+tab = [3, 10, 1, 4, 5, 9, 8]
+
+n = len(tab)
+
+for i in range(0, n - 1):
+	for j in range(0, n - i - 1):
+		print ("j: "+str(j))
+		if (tab[j] > tab[j + 1]):
+			tab[j], tab[j+ 1] = tab[j + 1], tab[j]
+			
+print(tab)