// Vector sample code 1

using namespace std;
#include <iostream>
#include <vector>
void print(const vector<int> &);
void print_backwards(const vector<int> &);

int main()
{
  vector<int> v;
  int number;

  cout << "Input some integers.  Press Ctrl+D to end input.\n";
  while(cin >> number) {
    v.push_back(number);
  }

  print(v);
  print_backwards(v);
}

// Goes backwards in the vector and prints out integers 
// (starting with last element first).  NOTE: The last
// element in the vector is not a.size(), it's a.size()-1.
void print_backwards(const vector<int> & a)
{
  int i;
  for(i = a.size()-1; i >= 0; i--)
    cout << a[i] << " ";

  cout << endl;
  cout << "----------------"<< endl;
}

// Goes fowards in the vector and prints out integers
void print(const vector<int> & a)
{
  int i;
  for(i = 0; i < a.size(); i++)
    cout << a[i] << " ";

  cout << endl;
  cout << "----------------"<< endl;
}

