So I am trying to write a code to take the three numbers, input from the user, and use a bubble sort to sort them in ascending order. Then take the middle value and out-put it. This is what I've got so far, but I can't think how to call the middle value
int main(void)
{
cout << "Please input three numbers: " << endl;
float ValueA, ValueB, ValueC; //-- Create floats for the three inputs.
cout << "Number one: ";
cin >> ValueA;
cout << "Number two: ";
cin >> ValueB;
cout << "Number three: ";
cin >> ValueC;
int temp = -1; //-- Create a temporary storage for swapping numbers.
// Set parameters for the number of times the loop can run.
int end = 3;
int length = 3;
int input[] = {ValueA, ValueB, ValueC};
//-- Create loop to swap numbers in order, and run this loop three times
for(int counter = length - 1; counter > 0; counter--)
{
for (int index = 0; index < end; index++)
{
if (input[index] > input[index + 1])
{
temp = input[index + 1];
input[index +1] = input[index];
input[index] = temp;
}
}
end--;
}
cout << "The numbers in order are: ";
for(int index = 0; index < 3; index++)
{
cout << input[index] << ", ";
}
//- Display the middle value
cout << "The middle value is: " < endl;
system("pause");
return 0;
} // End main