bub_sort.py

To łatwe, wiem o tym ale nie mam niczego innego ciekawego do pokazania z pythona, coś napiszę lepszego jeszcze i będzie git.
This commit is contained in:
Arkadiusz Charliński 2021-11-29 04:58:58 +01:00
parent bdaacbd9eb
commit c017df8358
1 changed files with 24 additions and 0 deletions

24
Bubble sort Normal file
View File

@ -0,0 +1,24 @@
lstlen = int(input())
lst = [int(x) for x in input().split()]
nr = True
x = 0
while True:
while x < ((lstlen) - 1):
if lst[x] > lst[x + 1]:
a, b = lst[x], lst[x + 1]
lst[x], lst[x+1] = b, a
x += 1
nr = False
else:
x += 1
if nr:
break
else:
lstlen -= 1
nr = True
x = 0
for j in range(len(lst)):
print(lst[j],end=" ")