Write a program to compute and print the quartiles (that is, the quarter of the numbers
with the largest values, the next highest quarter, and so on) of a set of integers .
This is giving me some problems. I am able of finding q2 what would be the median but how would I devide the entire set of integers into an upper and a lower half? This is the code I got so far:
using std::cout; using std::cin;
// Ask for the numbers.
cout << "Please enter the set of integers: \n";
//Integers is a vector that will hold the set f integers while "x" is the currently processed integer.
while(cin >> x)
// Sorting the set of integers.
// Count the amount of integers given and store the result.
const unsigned int r = integers.size();;
// See if a set of numbers has been given.
if(r == 0)
cout << "No set of integers was entered. Please try again.";
// Calculate Q2.
q2 = r % 2 == 0 ? (integers[mid] + integers[mid -1]) / 2 : integers[mid];