Oscar A.

asked • 04/12/20

Given a sorted list of integers, output the middle integer. Assume the number of integers is always odd.

Given a sorted list of integers, output the middle integer. Assume the number of integers is always odd.

Ex: If the input is:

2 3 4 8 11 -1

(a negative indicates the end), the output is:

4

The maximum number of inputs for any test case should not exceed 9. If exceeded, output "Too many inputs".

Hint: First read the data into a vector. Then, based on the number of items, find the middle item.


#include <iostream>

#include <vector> // Must include vector library to use vectors

using namespace std;


int main() {


/* Type your code here. */


return 0;

}


1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.