#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
template<typename T> void swap(T *a, T *b) {
T temp = *a;
*a = *b;
*b = temp;
}
void bubbleSort(vector<int> &arr) {
int len = arr.size();
for (int i = len; i > 1; i--) {
int swapped = 0;
for (int j = 1; j < i; j++) {
int a = arr[j];
int b = arr[j-1];
if (arr[j] < arr[j - 1]) {
swap(&arr[j], &arr[j-1]);
swapped = 1;
}
}
if (!swapped) {
break;
}
}
}
void showPlay(int temp) {
cout << temp << ' ';
return;
}
int main()
{
vector<int> test {9,8,7,6,5};
bubbleSort(test);
for_each(test.begin(), test.end(), showPlay);
return 0;
}