C++ Tutorial/deque/deque reverse — различия между версиями

Материал из C\C++ эксперт
Перейти к: навигация, поиск
м (1 версия: Импорт контента...)
 
(нет различий)

Текущая версия на 10:29, 25 мая 2010

Use reverse function on deque

#include <iostream>
#include <cassert>
#include <string>
#include <deque>
#include <algorithm> // for reverse
using namespace std;
int main()
{
  string s("abcdef");

  deque<char> deque1(s.begin(), s.end());
  deque<char>::iterator i;
  for (i = deque1.begin(); i != deque1.end(); ++i)
    cout << *i;
  cout << "\n\n\n";
  reverse(deque1.begin(), deque1.end());
  for (i = deque1.begin(); i != deque1.end(); ++i)
    cout << *i;
  return 0;
}
abcdef

fedcba"