Printing quartiles from list of ints

I couldn't find a solid example on the net of this so I was wondering if there was a more elegant way of printing the quartiles.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cout << "Welcome to Quartiles!" << endl;
cout << "Please enter a set of integers: "

int x;
vector<int> vec;

while (cin >> x) vec.push_back(x);

sort(vec.begin(), vec.end());

int size = vec.size();

int i = 0;							// loop counter
cout << endl;
for (i; i < size / 4; i++) cout << vec[i] << " ";		// Q1
cout << endl;
for (i; i < size / 2; i++) cout << vec[i] << " ";		// Q2
cout << endl;
for (i; i < size / 2 + size / 4; i++) cout << vec[i] << " ";	// Q3
cout << endl;
for (i; i < size; i++) cout << vec[i] << " ";			// Q4
cout << endl;
Topic archived. No new replies allowed.