Sorting algorithms/Bubble sort: Difference between revisions
Content added Content deleted
(→{{header|C}}: there is no point in making a local variable const) |
|||
Line 227: | Line 227: | ||
=={{header|C}}== |
=={{header|C}}== |
||
<lang c>void bubble_sort(int *a, int n) { |
<lang c>void bubble_sort(int *a, int n) { |
||
int |
int j, t = 1; |
||
while (n-- && t) |
|||
for (j = t = 0; j < |
for (j = t = 0; j < n; j++) { |
||
if (a[j] <= a[j + 1]) continue; |
if (a[j] <= a[j + 1]) continue; |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
} |
||
} |
|||
} |
} |
||