// note this top counter, i, counts down
for (int i=NMAX-1; i>0; i--)
{
//and this counter, j, only goes as far as the current i value
// it means it doesn't go over the elements that have already 'bubbled up' to the end of the array
for (int j=0; j<i; j++)
{
double temp;
// Compare 2 values - increment a counter here
if (Numbers[j]>Numbers[j+1])
{
temp = Numbers[j];
Numbers[j]= Numbers[j+1];
Numbers[j+1]= temp;
//increment a swap counter here
}
}
}
// display the sorted array:
cout<<"ARRAY CONTENTS SORTED, IMPLEMENTATION 1 "<<endl;
for (int i=0; i<NMAX; i++)
{
cout<<Numbers[i]<<endl;
}
//Display the values of the counter after the whole sort
return 0;
}