vector容器中实现可以通过以下两种方式实现:

#include "stdafx.h"
#include <vector>
#include <iostream>
//#include <math.h> #include <algorithm> using namespace std; int _tmain(int argc, _TCHAR* argv[])
{ vector<int> arrayInt;
arrayInt.resize();
for (int i=;i<;i++)
{
arrayInt[i]=i;
} vector<int> arrayRever;
arrayRever.reserve(arrayInt.size()); //vector反转 //------------------------------------------------------------------------------
//>>>
//方法一:使用vector自带的反转迭代器reverse_iterator,rbegin(),rend()
vector<int>::reverse_iterator riter;
for (riter=arrayInt.rbegin();riter!=arrayInt.rend();riter++)
{
arrayRever.push_back(*riter);
}
//<<<
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//>>>
//方法二:使用<algorthm>中的reverse()
//arrayRever=arrayInt;
//reverse(arrayRever.begin(),arrayRever.end());
//<<<
//------------------------------------------------------------------------------ //
for (int i=;i<arrayRever.size();i++)
{
cout<<"arrayRever["<<i<<"]"<<" "<<arrayRever[i]<<endl;
} return ;
}

最新文章

  1. 17、ASP.NET MVC入门到精通——Spring.net入门
  2. Bullet物理引擎在OpenGL中的应用
  3. 【iCore3双核心板】iCore3双核心板使用说明(图文)
  4. 浅谈PHP与手机APP开发(API接口开发)
  5. 基于Html5的兼容所有主流浏览器的在线视频播放器videoJs
  6. linux网络配置相关文件
  7. 第27本:《学得少却考得好Learn More Study Less》
  8. ava集合---LinkedList源码解析
  9. Delegate &amp; Event
  10. CC2640蓝牙芯片开发备记
  11. no plugin found for prefix &#39;tomcat 7&#39; in the current project and in the plugin groups的解决方法
  12. Js中instanceof 的用法
  13. Loadrunner和JMeter并发对比
  14. Python Redis list
  15. unigui结合JS方法记录
  16. [Java程序员面试宝典]读书笔记
  17. leetcode 算法 Excel表列序号 python实现
  18. vi命令速查图
  19. Kotlin中的object 与companion object的区别
  20. linux 的 磁盘管理

热门文章

  1. Linux多线程下载工具Axel
  2. Can&#39;t locate ExtUtils/MakeMaker.pm
  3. Spring中@Resource与@Autoware
  4. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.5. 配置网络
  5. ArcGlobe点击IGlobeServerLayer图层读取信息
  6. 分享一些Comet开发经验
  7. OFBIZ安装
  8. Basic Sorting Algorithms
  9. Application Cache
  10. asp.net mvc让我告诉你请求从哪里来