annotate bubblesort/bubblesort.py @ 6:709bdcd2937b

vsss-0.230913-0.2_PKG_PATH
author prymula <prymula76@outlook.com>
date Thu, 01 Feb 2024 21:45:12 +0100
parents dcd610585610
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1 #!/usr/bin/env python3
prymula <prymula76@outlook.com>
parents:
diff changeset
2
prymula <prymula76@outlook.com>
parents:
diff changeset
3 tab = [3, 10, 1, 4, 5, 9, 8]
prymula <prymula76@outlook.com>
parents:
diff changeset
4
prymula <prymula76@outlook.com>
parents:
diff changeset
5 n = len(tab)
prymula <prymula76@outlook.com>
parents:
diff changeset
6
prymula <prymula76@outlook.com>
parents:
diff changeset
7 for i in range(0, n - 1):
prymula <prymula76@outlook.com>
parents:
diff changeset
8 for j in range(0, n - i - 1):
prymula <prymula76@outlook.com>
parents:
diff changeset
9 print ("j: "+str(j))
prymula <prymula76@outlook.com>
parents:
diff changeset
10 if (tab[j] > tab[j + 1]):
prymula <prymula76@outlook.com>
parents:
diff changeset
11 tab[j], tab[j+ 1] = tab[j + 1], tab[j]
prymula <prymula76@outlook.com>
parents:
diff changeset
12
prymula <prymula76@outlook.com>
parents:
diff changeset
13 print(tab)