Kody źródłowe/Sortowanie przez wstawianie: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
Nie podano opisu zmian
AkBot (dyskusja | edycje)
m bot poprawia starą składnię wiki
Linia 8:
== C ==
Wersja klasyczna:
<sourcesyntaxhighlight lang="c">
void insertSort(int a[], int length)
{
Linia 20:
}
}
</syntaxhighlight>
</source>
Wersja z wyszukiwaniem połówkowym:
<sourcesyntaxhighlight lang="c">
void insertionsortwithsearch(int table[], int size)
{
Linia 50:
}
}
</syntaxhighlight>
</source>
 
== C++ ==
<sourcesyntaxhighlight lang="cpp">
void SortInsert::insertSort(vector<int>::iterator begin, vector<int>::iterator end)
{
Linia 60:
std::iter_swap((j - 1), j);
}
</syntaxhighlight>
</source>
 
== Ocaml ==
<sourcesyntaxhighlight lang="ocaml">
let rec insertsort list =
let rec insert element list =
Linia 75:
| [] -> []
| h :: t -> insert h (insertsort t)
</syntaxhighlight>
</source>
 
== Python ==
<sourcesyntaxhighlight lang="python">
def Insert_sort(A):
for i in range(1,len(A)):
Linia 87:
j = j - 1
A[j + 1] = klucz
</syntaxhighlight>
</source>
 
== Ruby ==
<sourcesyntaxhighlight lang="ruby">
class Array
def insert_sort!(&sort_by)
Linia 111:
end
end
</syntaxhighlight>
</source>
 
== PHP ==
<sourcesyntaxhighlight lang="PHP">
function InsertionSort($tab)
{
Linia 148:
echo $k." ";
}
</syntaxhighlight>
</source>
 
== SML ==