// Sorting arrays -- BUBBLE SORT

#include <iostream>
#include <iomanip>		//For setting the width

using namespace std;
#define ARRAY_SIZE 15

void print_array(int A[]) {
	int i;
	for (i=0;i<ARRAY_SIZE;i++) {
		cout.width(4);
		cout << A[i];
	}
	cout << endl;
} //end print_array

void main() {

	int Array[ARRAY_SIZE] = {34,12,32,51,11,7,98,15,38,14,55,34,87,91,24};

	print_array(Array);
	
	int i, j;
	int temp;

	for (i=0;i<=(ARRAY_SIZE-1);i++) {
		for( j=0; j<=(ARRAY_SIZE-2); j++) {
			if (Array[j] > Array[j+1]) {
				//Swap the two
				temp = Array[j];
				Array[j] = Array[j+1];
				Array[j+1] = temp;
			}
		} //end for(j)
	}//end for (i)

	print_array(Array);

} //end main()