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