Anonymous user
Sorting algorithms/Insertion sort: Difference between revisions
→{{header|C}}: size should be an unsigned int, size_t is even better because it uses the proper size for your architecture (32-bit on x86, 64-bit on x86_64)
(→{{header|C}}: make function declaration valid) |
(→{{header|C}}: size should be an unsigned int, size_t is even better because it uses the proper size for your architecture (32-bit on x86, 64-bit on x86_64)) |
||
Line 190:
=={{header|C}}==
size_t i, j;
▲void insertion_sort(int *a, int n) {
int
for (i = 1; i < n; i++) {
for (j = i; j > 0 &&
a[j] = a[j - 1];
}
a[j] =
}
}
Line 204:
int main(void) {
int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1};
insertion_sort(a, n);
return 0;
|