In the following listing I have used cin.get() to keep the console window open when I run the .exe file - it has worked before for me but in this program it doesn't - the console shuts immediately after outputting the list - I just know this is going to be something obvious so sorry in advance!!
Code:
#include <algorithm>
#include <iostream>
#include <istream>
#include <ostream>
#include <vector>
using namespace std;
int main()
{
vector<int> data; // initialized to be empty
int x(0);
// Read integers one at a time.
while (cin >> x)
// Store each integer in the vector.
data.push_back(x);
// Sort the vector.
sort(data.begin(), data.end());
// Print the vector, one number per line.
for (vector<int>::size_type i(0); i != data.size(); i = i + 1)
{
cout << data.at(i) << '\n';
}
cin.get();