Anonymous user
Sorting algorithms/Insertion sort: Difference between revisions
Fixed a few naming and operator issues. "Isort" to "insertion_sort". "i <= n - 1" to "i < n". "j -= 1" to "j--". That sort of thing.
(→{{header|Groovy}}: swap dots added) |
(Fixed a few naming and operator issues. "Isort" to "insertion_sort". "i <= n - 1" to "i < n". "j -= 1" to "j--". That sort of thing.) |
||
Line 190:
=={{header|C}}==
<lang c
void insertion_sort (int *a, int n) {
for (j = i - 1; j >= 0 && k < a[j]; j--) {
a[j + 1] = a[j];▼
▲ a[j+1] = a[j];
}
}
int main (
int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1};
int
return 0;
}
▲ for(i=0; i<=n-1; i++)
▲}</lang>
=={{header|C++}}==
|