#include <iostream>
using namespace std;
void bubble_sort(int *a, int length)
{
for (int i = 0; i < length-1; i++) {
bool swapped = false;
for (int j = 0; j < length-i-1; j++) {
if (a[j] > a[j+1]) {
int b = a[j];
a[j] = a[j+1];
a[j+1] = b;
swapped = true;
}
}
if(!swapped)
break;
}
}
int main(){
int i, n;
int A[] = {-1, 3, -8, 14, 5, 2, 15};
n = sizeof(A)/sizeof(A[0]);
cout<<"\nINPUT : ";
for( i = 0; i < n; i++ )
cout<<A[i]<<" ";
bubble_sort(A, n);
cout<<"\nOUTPUT : ";
for( i = 0; i < n; i++ )
cout<<A[i]<<" ";
return 0;
}