deque-begin

////////////////////////////////////////
//      2018/04/23 14:31:31
//      deque-begin

#include <iostream>
#include <deque>
#include <iterator>
#include <numeric>

using namespace std;

int main(){
    deque<int> d(5);
    iota(d.begin(), d.end(), 1);

    deque<int>::iterator it = d.begin();
    while (it != d.end()){
        cout << *(it++) << " ";
    }
    cout << endl;

    // third element of the deque
    it = d.begin() + 2;
    cout << *it << endl;
    return 0;
}

/*
OUTPUT:
    1 2 3 4 5
    3
*/ 
posted @ 2018-04-23 14:45  老耗子  阅读(22)  评论(0编辑  收藏  举报