deque-assign

////////////////////////////////////////
//      2018/04/23 12:04:42
//      deque-assign
#include <iostream>
#include <deque>
#include <algorithm>
#include <iterator>

using namespace std;

int main(){
    int ary[] = { 1, 2, 3, 4, 5 };
    deque<int> d;

    // assign to the "d" the contains of "ary"

    d.assign(ary, ary + 5);
    copy(d.begin(), d.end(), ostream_iterator<int>(cout, " "));
    cout << endl;

    // replace d for 3 copies of 100
    d.assign(3, 100);
    copy(d.begin(),d.end(), ostream_iterator<int>(cout," "));
    cout << endl;

    return 0;
}


/*
OUTPUT:
    1 2 3 4 5
    100 100 100
*/ 
原文地址:https://www.cnblogs.com/laohaozi/p/12538016.html