Sorting algorithms/Bubble sort: Difference between revisions
Content deleted Content added
Line 377:
=={{header|C++}}==
<lang cpp>#include <algorithm>
#include <
// Sorts anything that provides random access iterators.
template <typename RAIterator> void bubble_sort(
RAIterator end) {
using std::swap;
while (begin != end--) {
if (*(i + 1) < *i) {▼
{▼
▲ {
}
}
}
int main() {▼
copy(std::begin(a), std::end(a), std::ostream_iterator<int>(std::cout, " "));
▲int main()
▲ bubble_sort(array, 10);
▲ int data[] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
}</lang>
Output:
<pre>
-199 -52 2 3 33 56 99 100 177 200
</pre>
=={{header|C sharp|C#}}==
|