#include void swapif(int & x, int & y) { if (x > y) { int temp = x; x = y; y = temp; } } void main() { const int N = 10; int a[N+1]; for (int i = 1; i <= N; i += 1) a[i] = random_in_range(1, 99); for (int i = 1; i <= N; i += 1) cout << a[i] << " "; cout << "\n"; // The next three lines do all the sorting. // all the rest of the program is just preparing and displaying the data. for (int end = N - 1; end >= 1; end -= 1) for (int first = 1; first <= end; first += 1) swapif(a[first], a[first+1]); for (int i = 1; i <= N; i += 1) cout << a[i] << " "; cout << "\n"; }