Sorting algorithms/Bubble sort: Difference between revisions
Content deleted Content added
→{{header|C}}: main(void) |
→{{header|C}}: constant |
||
Line 226: | Line 226: | ||
=={{header|C}}== |
=={{header|C}}== |
||
<lang c>void bubble_sort(int *a, int n) { |
<lang c>void bubble_sort(int *a, const int n) { |
||
int i, j, t=1; |
int i, j, t=1; |
||
for (i = n - 1; i && t; i--) { |
for (i = n - 1; i && t; i--) { |
||
Line 240: | Line 240: | ||
int main(void) { |
int main(void) { |
||
int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1}; |
int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1}; |
||
bubble_sort(a, sizeof(a) / sizeof(a[0])); |
|||
bubble_sort(a, n); |
|||
return 0; |
return 0; |