#include <iostream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <vector>

using std::vector;
using std::copy;
using std::partial_sort;
using std::cout;
using std::cin;
using std::ostream_iterator;
using std::greater;

vector<int> getValues(int howmany);
void displayValues(const vector<int>& values);
int largest(vector<int>& values);
int smallest(vector<int>& values);
void displayLargestSmallest(vector<int>& values);


vector<int> getValues(int howmany)
{
    vector<int> values;
    int value = 0;
    
    while (howmany > 0)
    {
        cout << "Enter a number: ";
        cin >> value;
        values.push_back(value);
        howmany -= 1;
    }
    return values;
}

void displayValues(const vector<int>& values)
{
    cout << "Values entered:\n";
    copy(values.begin(), values.end(), ostream_iterator<int>(cout, "\n"));
}

int smallest(vector<int>& values)
{
    partial_sort(values.begin(), values.begin() + 1, values.end());
    return values.at(0);
}

int largest(vector<int>& values)
{
    partial_sort(values.begin(), values.begin() + 1, values.end(), greater<int>());
    return values.at(0);
}

void displayLargestSmallest(vector<int>& values)
{
    cout << "smallest number is " << smallest(values) << "\n";
    cout << "largest number is " << largest(values) << "\n";
}

int main()
{
    const int SIZE = 10;
    vector<int> values = getValues(SIZE);
    displayValues(values);
    displayLargestSmallest(values);
    return 0;
}