From c017df835880cf6e377a19f73d915b9724e209af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Charli=C5=84ski?= Date: Mon, 29 Nov 2021 04:58:58 +0100 Subject: [PATCH] bub_sort.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To łatwe, wiem o tym ale nie mam niczego innego ciekawego do pokazania z pythona, coś napiszę lepszego jeszcze i będzie git. --- Bubble sort | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Bubble sort diff --git a/Bubble sort b/Bubble sort new file mode 100644 index 0000000..9b739c5 --- /dev/null +++ b/Bubble sort @@ -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=" ") \ No newline at end of file