#include <cstddef>
#include <iostream>
#include <algorithm>
#include <string>

template <typename iter>
void print(iter begin, iter end, const std::string& separator = " ", const std::string& terminator = "\n", std::ostream& os = std::cout)
{
    while (begin != end)
    {
        os << *begin++ ;

        if (begin != end)
            os << separator;
    }

    os << terminator;
}

void myreverse(int* beg, int* end)
{
    using std::swap;

    if (beg && end && beg < --end)
        while (beg < end)
            swap(*beg++, *end--);
}

int main()
{
    const std::size_t size = 5;
    int arr[size] = { 1, 2, 3, 4, 5 };

    int* arr_beg = arr;
    int* arr_end = arr + size;

    print(arr_beg, arr_end, ", ");

    std::reverse(arr_beg, arr_end);
    print(arr_beg, arr_end, ", ");

    myreverse(arr_beg, arr_end);
    print(arr_beg, arr_end, ", ");
}