• 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
    */
  • 相关阅读:
    C语言考点例题解析
    五笔打字
    常用快捷键
    网络基础知识
    人口增长
    8 封装
    9 绑定方法和非绑定方法
    6 抽象类
    7 多态和多态性
    5 组合
  • 原文地址:https://www.cnblogs.com/laohaozi/p/12537983.html
Copyright © 2020-2023  润新知