Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

C++: Inverser le contenu d’un deque

 assert, deque
{filelink=14993}

 
#include <iostream>
#include <cassert>
#include <string>
#include <deque>
#include <algorithm> // pour la fonction reverse
using namespace std;
 
int main()
{
 
deque<char> deq;
for(int x=0;x<26;x++)
   deq.push_back(x+'A');
 
  deque<char>::iterator i;
 
  for (i = deq.begin(); i != deq.end(); ++i)
    cout << *i;
 
  cout << "n";
 
  //Inverser le contenu
  reverse(deq.begin(), deq.end());
 
  for (i = deq.begin(); i != deq.end(); ++i)
    cout << *i;
 
  return 0;
}

No comments yet.

Leave a Comment