deque-resize

////////////////////////////////////////
//      2018/04/25 7:45:29
//      deque-resize
#include <iostream>
#include <deque>
#include <algorithm>
#include <iterator>

using namespace std;

int main(){
    deque<int> d(5);

    for (int i = 0; i < 5; i++){
        d[i] = i*2;
    }
    copy(d.begin(),d.end(), ostream_iterator<int>(cout," "));
    cout << endl;

    d.resize(7, 100);
    copy(d.begin(), d.end(), ostream_iterator<int>(cout, " "));
    cout << endl;

    d.resize(4);
    copy(d.begin(), d.end(), ostream_iterator<int>(cout, " "));
    cout << endl;
    return 0;
}

/*
OUTPUT:
    0 2 4 6 8
    0 2 4 6 8 100 100
    0 2 4 6
*/
原文地址:https://www.cnblogs.com/laohaozi/p/12537983.html