首页 > 编程语言 > 详细

c++ 容器反转并且拷贝到一个新容器中

时间:2019-05-20 01:00:59      阅读:198      评论:0      收藏:0      [点我收藏+]

 

// reverse_copy example
#include <iostream>     // cout
#include <algorithm>    // reverse_copy
#include <vector>       // vector
using namespace std;
int main () {
  int myints[] ={1,2,3,4,5,6,7,8,9};
  vector<int> myvector;

  myvector.resize(9);    // allocate space

  reverse_copy (myints, myints+9, myvector.begin());

  // print out content:
  cout << "myvector contains:";
  for (vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
    cout <<   << *it;

  cout << \n;

  return 0;
}

 

c++ 容器反转并且拷贝到一个新容器中

原文:https://www.cnblogs.com/sea-stream/p/10891743.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!