#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 << '\n';

    

    return 0;

}

相关文章:

  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2021-11-24
  • 2021-11-04
猜你喜欢
  • 2021-06-10
  • 2022-02-24
  • 2022-12-23
  • 2022-02-02
  • 2022-01-25
  • 2022-12-23
  • 2021-11-29
相关资源
相似解决方案