reverse an array : vector reverse « vector « C++ Tutorial






#include <iostream>
#include <algorithm>

using namespace std ;

int main(void)
 {
   double A[6] = { 1.2, 1.3, 1.4, 1.5, 1.6, 1.7 };
   int i;

   for (i = 0; i < 6; ++i)
     cout << "A[" << i << "] = " << A[i] << "  ";
   cout << endl;
   reverse(A, A + 6);
   for (i = 0; i < 6; ++i)
     cout << "A[" << i << "] = " << A[i] << "  ";
   cout << endl;
 }








16.22.vector reverse
16.22.1.Reverse all elements in a vector by using reverse
16.22.2.reverse an array
16.22.3.Use merge with back_inserter