zoukankan      html  css  js  c++  java
  • c++ 指定长度容器元素的拷贝(copy_n)

    #include <iostream>     // cout

    #include <algorithm>    // copy

    #include <vector>       // vector

    using namespace std;

    int main () {

        int myints[]={10,20,30,40,50,60,70};

        vector<int> myvector;

        

        myvector.resize(2);   // allocate space for 7 elements

        

        copy_n ( myints, 5, myvector.begin() );

        

        cout << "myvector contains:";

        for (vector<int>::iterator it = myvector.begin(); it!=myvector.end(); ++it)

            cout << ' ' << *it;

        

        cout << ' ';

        

        return 0;

    }

  • 相关阅读:
    PHP学习之路(六)
    PHP学习之路(五)
    PHP学习之路(四)
    PHP学习之路(三)
    PHP学习之路(二)
    PHP学习之路(一)
    webstrom运行出现404的解决办法
    适配移动端Swiper的3D旋转木马轮播~
    为什么觉得英文字体设计比中文字体设计来的好看?
    linux 部署系统通过SecureCRT启动tomcat 控制台中文乱码
  • 原文地址:https://www.cnblogs.com/sea-stream/p/9816167.html
Copyright © 2011-2022 走看看