Difference between revisions 540848 and 540877 on plwikisource{{Nagłówek |tytuł=Sortowanie bąbelkowe |sekcja=Kod źródłowy |adnotacje={{Wikipedia|strona=Sortowanie bąbelkowe|dopełniacz=Sortowanie bąbelkowe}} }} {{Spis treści}} ==BASH== * <tt>$lz</tt> - ilość liczb do posortowania (contracted; show full) for (int pass = 1; pass < ar.Length; pass++) for (int i = 0; i < ar.Length - 1; i++) if (ar[i] > ar[i + 1]) Swap(ar, i); } </source> $b= "ssijcie"; echo $b;==PHP== <source lang="PHP"> $a = array (3, 7, 14, 1, 20, 14, 15); //Utworzenie tablicy $n = count($a); //Zliczenie elementów tablicy do zmiennej $n for ($i = 1; $i < $n; $i++) for ($j = $n - 1; $j >= $i; $j--) if ($a[$j - 1] > $a[$j]) //Porównanie sąsiednich elementów tablicy list($a[$j - 1], $a[$j]) = array($a[$j], $a[$j - 1]); //Zamiana miejscami dwóch elementów tablicy </source> ==Pascal== <source lang=Pascal>Const numbers = 6; // ilość sortowanych komórek w tablicy Type table = Array[1..numbers] Of Integer; (contracted; show full) public void bubbleSort(Integer[] a) { for (int i = 0, size = a.length - 1; i < a.length - 1; i++, size--) for (int j = 0; j < size; j++) for (int temp = a[j]; a[j] > a[j + 1]; a[j] = a[j + 1], a[j + 1] = temp) ; } </source> [[Kategoria:Kody źródłowe]] All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://pl.wikisource.org/w/index.php?diff=prev&oldid=540877.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|