Difference between revisions 426333 and 426335 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) } if(!change) break; // nie dokonano zmian - koniec! } } </source> Wersja z zapamiętaniem miejsca ostatniej zamiany: <source lang="C"> void bubblesortlastchange(int tab le[], int size) { int i, j, temp, swapped, loop; swappedloop, last, i, j, temp; last = size; - 1;⏎ for (i = size- - 1; i > 0; i--) { loop = swapped; swappedlast; last = 0; for (j = 0; j < loop; j++) { if (table[j] > table[j+1]) { swapped last = j+ + 1; temp = table[j+1[j]; table[j+1[j] = table[j+1]; table[j+1] = temp; } } } }⏎ </source> ==C++== <!-- Przepisany na C++ pseudokod z angielskiej Wikipedii --> <source lang="Cpp"> template <class T> void bubble_sort(T* tab, int n) { bool swapped; // Czy zamieniono w ostatnim obrocie? (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=426335.
![]() ![]() 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.
|