// Program to read in integers and print in two columns.
//
// Input:  sequence of N integers read from standard input.
// Output:  input sequence of integers printed to standard output in
//            two-column format, with first column containing first 
//            (N+1)/2 numbers and second column containing remaining 
//            numbers.
//
// This version does not use the STL, but uses a dynamic array.


#include <iostream.h>
#include <stdlib.h>		// has EXIT_SUCCESS
#include <cstddef>		// has NULL

typedef unsigned int v_size_t;

int main(void)
{
  // vector<int> v;
  v_size_t size = 0;		// size of v
  int * v = NULL;		// to point to array of numbers so far

  int temp;

  cout << "Enter some integers, control-D to end:\n";
  while (cin >> temp)
    {
      //v.push_back(temp);
      int * temp_v = v;
      v = new int[size+1];
      for (unsigned int j = 0; j < size; ++j)
	v[j] = temp_v[j];
      delete [] temp_v;
      ++size;
      v[size-1] = temp;
    }
      
  // v_size_t size = v.size();

  for (v_size_t i = 0; i < size/2; ++i)
    cout << v[i] << "\t" << v[i + (size+1)/2] << endl;

  if (size % 2 != 0)
    cout << v[size/2] << endl;

  return EXIT_SUCCESS;
}