From 06661aece728f6ebb4579484281bf772683aeebb Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Fri, 25 Oct 2019 18:13:43 +0200 Subject: [PATCH] =?UTF-8?q?04:=20Je=C5=A1t=C4=9B=20bublinkov=C3=A9=20t?= =?UTF-8?q?=C5=99=C3=ADd=C4=9Bn=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-trideni/trideni-bublinky.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 04-trideni/trideni-bublinky.py diff --git a/04-trideni/trideni-bublinky.py b/04-trideni/trideni-bublinky.py new file mode 100755 index 0000000..f8c74a8 --- /dev/null +++ b/04-trideni/trideni-bublinky.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# Třídění probubláváním + +x = [31, 41, 59, 26, 53, 58, 97] + +n = len(x) +for i in range(n): + for j in range(n-1): + if x[j] > x[j+1]: + x[j], x[j+1] = x[j+1], x[j] + +print(x) -- GitLab