#include using namespace std; void order(int & x, int & y) { if (x < y) return; int temp = x; x = y; y = temp; } void sort(int R[], int N) { int steps = 0; int j = N - 2; while (j >= 0) { int i = 0; while (i <= j) { order(R[i], R[i+1]); steps += 1; i += 1; } j -= 1; } cout << "Took " << steps << " steps\n"; } int main() { int a[100], i, N; cout << "How many numbers to sort? "; cin >> N; cout << "Enter the varibales' values: "; i = 0; while (i < N) { cin >> a[i]; i += 1; } sort(a, N); i = 0; while (i < N) { cout << a[i] << " "; i += 1; } cout << "\n"; }