Inverser l’ordre des éléments d’un tableau avec l’algorithme ‘reverse()’

Author:

 assert, iterator
Download


#include 
#include 
#include 
#include 
using namespace std;

int main()
{
  char tab[] = "abc";
  int size = strlen(tab);
  reverse(&tab[0], &tab[size]);
  assert (string(tab) == "cba");
  copy(tab, tab+3, ostream_iterator(cout," "));
  return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *