Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

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

 assert, iterator
{filelink=15115}

 
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
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<char>(cout," "));
  return 0;
}

No comments yet.

Leave a Comment