Anonymous user
Sorting algorithms/Bubble sort: Difference between revisions
→{{header|C}}: Avoid too many actions on one line. Use another variable to track when swaps happen vs the swap temporary.
(Add Nimrod) |
(→{{header|C}}: Avoid too many actions on one line. Use another variable to track when swaps happen vs the swap temporary.) |
||
Line 359:
=={{header|C}}==
<lang c>void bubble_sort(int *a, int n) {▼
int i, t, s = 1;
if (a[i] < a[i - 1]) {
t = a[i];
a[i] = a[i - 1];
a[i - 1] = t;
s = 1;
}
}
}
}
int main (
}
▲}</lang>
</lang>
=={{header|C++}}==
|