vector Construct
#include<vector>
#include<iostream>
using namespace std;
void Test(); void main()
{
int a[]={,,,,};
vector<int> v_a(a,a+);
vector<int> v_b(v_a.begin(),v_a.end()); vector<int>::iterator it;
for (it=v_a.begin();it!=v_a.end();++it)
{
cout<<*it<<" ";
}
cout<<endl; ///////////////////////
for (it=v_b.begin();it!=v_b.end();++it)
{
cout<<*it<<" ";
}
cout<<endl; ///////////////////////
Test();
} void Test()
{
int a[]={,,,,};
vector<int> v_a(a,a+);
vector<int> v_b(v_a.begin(),v_a.end()); vector<int>::iterator it;
for (it=v_a.begin();it!=v_a.end();++it)
{
cout<<*it<<" ";
}
cout<<endl; ///////////////////////
for (it=v_b.begin();it!=v_b.end();++it)
{
cout<<*it<<" ";
}
cout<<endl; /////////////////////// } // 1 2 3 4 5
// 1 2 3 4 5
// 1 2 3 4
// 1 2 3 4
// Press any key to continue
vector Construct的更多相关文章
- OpenFOAM 中 c++ 基础
文件布置 在 OpenFOAM 中,所有代码都以注释段开头,使用有限体积的 CFD 类型文件都包括以下头文件 #include "fvCFD.H" 在此头文件种,仅包含类或函数的定 ...
- [LeetCode] Construct Binary Tree from Inorder and Postorder Traversal 由中序和后序遍历建立二叉树
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume tha ...
- [LeetCode] Construct Binary Tree from Preorder and Inorder Traversal 由先序和中序遍历建立二叉树
Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...
- 模板化的七种排序算法,适用于T* vector<T>以及list<T>
最近在写一些数据结构以及算法相关的代码,比如常用排序算法以及具有启发能力的智能算法.为了能够让写下的代码下次还能够被复用,直接将代码编写成类模板成员函数的方式,之所以没有将这种方式改成更方便的函数模板 ...
- Leetcode Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that ...
- [c++] vector的使用
} { vec.push_back(value); } { vector< vector<,); vector<, sec ...
- 源码阅读笔记 - 2 std::vector (1)
vector的源码真是太长了,今天用了一个下午和一个晚上看和注释了前面的一千行左右 p.s.博客园的代码高亮真是太垃圾, 如果想要阅读带注释的源码,推荐粘贴到VS2015里,然后按ctrl+z取消自动 ...
- Construct Binary Tree from Inorder and Postorder Traversal
Construct Binary Tree from Inorder and Postorder Traversal Given inorder and postorder traversal of ...
- Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Preorder and Inorder Traversal Given preorder and inorder traversal of a ...
随机推荐
- ubuntu16安装python3
正常情况下,你安装好ubuntu16.04版本之后,系统会自带 python2.7版本,如果需要下载新版本的python3.5,就需要进行更新.下面给出具体教程: 1.首先在ubuntu的终端tern ...
- SQL Server -----创建sqlserver 数据库 、表
新建数据库 1.右击 选择新建数据库 2.起一个名字 选择保存位置 3.放在之前建好的的文件夹中 点击确定 4.都要选择好 点击确定 5.确定之后如图 6.新建表 7.见一个表,常说的要满足三大 ...
- 【转帖】Linux文件夹对比并提取的差分文件技巧-rsync的妙用
Linux文件夹对比并提取的差分文件技巧-rsync的妙用 [日期:2016-02-13] 来源:oschina.net 作者:mengshuai [字体:大 中 小] https://www.li ...
- Vue项目(vuecli3.0搭建)集成高德地图实现路线轨迹绘制
先看最后实现的效果图 高德地图api文档 https://lbs.amap.com/api/javascript-api/summary 使用 1.在index.html里面引入高德地图js文件 2. ...
- mybatis-plus 主键自增问题
主键不自增:返回值是插入的条数 <insert id="add" parameterType="EStudent"> insert into TSt ...
- 使用el-dialog时,报错“Unknown custom element:<el-dialog> did you register the component correctly?...make sure to provide the 'name' option”
初学vue时,曾遇到一个无语的问题,在用el-dialog时一直显示没有导入,结果发现是因为没有把element ui引入到项目里. 需进行以下步骤: 1.执行: npm install elemen ...
- Excel转换成xml文件
namespace ExcelToXml { class Program { [STAThread] static void Main(string[] args) { Program program ...
- MongoDB netcore
mongodb.driver mongodb.driver.core url: http://dl.mongodb.org/dl/win32/x86_64 ********************* ...
- tf.random_shuffle()函数解析
tf.random_shuffle(value, seed=None, name=None) 函数就是随机地将张量沿第一维度打乱 value:将被打乱的张量. seed:一个 Python 整数.用于 ...
- 老生常谈之js深拷贝与浅拷贝
前言 经常会在一些网站或博客看到"深克隆","浅克隆"这两个名词,其实这个很好理解,今天我们就在这里分析一下js深拷贝和浅拷贝. 浅拷贝 我们先以一个例子来说明 ...