// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <string>

using namespace std;

template<typename T>
void reverse(T *a, int n)
{
    for(int i = 0; i < n/2; i++)
    {
        T tmp = a[i];
        a[i] = a[n - 1 - i];
        a[n - 1 - i] = tmp;
    }
}

template<typename T>
void print(T *a, int n)
{
    for(int i = 0; i < n; i++)
    {
        cout << a[i] << endl;
    }
}

int main()
{
    int ia[] = { 1, 2, 3, 4};
    string sa[] = { "A", "BB", "CCC" };
    print(ia, 4);
    print(sa, 3);
    reverse(ia, 4);
    reverse(sa, 3);
    print(ia, 4);
    print(sa, 3);
    return 0;
}
