#include<algorithm>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;
typedef struct rect
{
int id;
int length;
int width; //对于向量元素是结构体的,可在结构体内部定义比较函数,下面按照id,length,width升序排序。
bool operator< (const rect &a) const
{
if(id!=a.id)
return id<a.id;
else
{
if(length!=a.length)
return length<a.length;
else
return width<a.width;
}
}
}Rect; int main()
{
std::vector<int> vecc;
for(int i=;i<;i++){
vecc.push_back(i);
} cout<<vecc[]<<endl;
vector<int> ::iterator itt;
for(itt=vecc.begin();itt!=vecc.end();itt++){
cout<<*itt<<endl;
}
vecc.insert(vecc.begin()+,);
cout<<vecc[]<<endl;
vecc.erase(vecc.begin()+);
cout<<vecc[]<<endl; vector<Rect> vec;
Rect rect;
rect.id=;
rect.length=;
rect.width=; vec.push_back(rect); vector<Rect>::iterator it=vec.begin();
cout<<(*it).id<<' '<<(*it).length<<' '<<(*it).width<<endl; getch();
return ;
}

 #include "opencv2/objdetect.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;
using namespace cv;
int main()
{
std::vector<int> vec;
vec.push_back();
vec.push_back();
vec.push_back();
vec.push_back();
cout<<vec[]<<endl;
vector<int>::iterator it;
for(it=vec.begin();it!=vec.end();it++){
cout<<"vector:"<<*it<<endl;
}
vec.insert(vec.begin()+,);
cout<<vec[]<<endl;
vec.erase(vec.begin()+);
cout<<vec[]<<endl;
cout<<vec.size()<<endl; getch();
return ;
}

 #include<stdio.h>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std; typedef struct rect
{
int id;
int length;
int width;   //对于向量元素是结构体的,可在结构体内部定义比较函数,下面按照id,length,width升序排序。
  bool operator< (const rect &a)  const
    {
        if(id!=a.id)
            return id<a.id;
        else
        {
            if(length!=a.length)
                return length<a.length;
            else
                return width<a.width;
        }
    }
}Rect; int main()
{
vector<Rect> vec;
Rect rect;
rect.id=;
rect.length=;
rect.width=;
vec.push_back(rect);
vector<Rect>::iterator it=vec.begin();
cout<<(*it).id<<' '<<(*it).length<<' '<<(*it).width<<endl; return ; }

C++———Vector的更多相关文章

  1. c++ vector 使用

    1. 包含一个头文件: 1 #include <vector> 2. 申明及初始化: std::vector<int> first; // empty vector of in ...

  2. Vector Tile

    Mapbox Vector Tile Specification A specification for encoding tiled vector data. <?XML:NAMESPACE ...

  3. ArrayList、Vector、LinkedList的区别联系?

    1.ArrayList.Vector.LinkedList类都是java.util包中,均为可伸缩数组. 2.ArrayList和Vector底层都是数组实现的,所以,索引数据快,删除.插入数据慢. ...

  4. ArrayList、Vector、HashMap、HashSet的默认初始容量、加载因子、扩容增量

    当底层实现涉及到扩容时,容器或重新分配一段更大的连续内存(如果是离散分配则不需要重新分配,离散分配都是插入新元素时动态分配内存),要将容器原来的数据全部复制到新的内存上,这无疑使效率大大降低. 加载因 ...

  5. Java中Vector和ArrayList的区别

    首先看这两类都实现List接口,而List接口一共有三个实现类,分别是ArrayList.Vector和LinkedList.List用于存放多个元素,能够维护元素的次序,并且允许元素的重复.3个具体 ...

  6. C++使用vector

    #include <iostream> #include <string> #include <vector> using namespace std; void ...

  7. [LeetCode] Flatten 2D Vector 压平二维向量

    Implement an iterator to flatten a 2d vector. For example,Given 2d vector = [ [1,2], [3], [4,5,6] ] ...

  8. C++ 数组array与vector的比较

    转:http://blog.csdn.net/yukin_xue/article/details/7391897 1. array 定义的时候必须定义数组的元素个数;而vector 不需要: 且只能包 ...

  9. vector定义初始化

    头文件 #include<vector> using std::vector; vector<T> v1; vector<T> v2(v1); vector< ...

  10. vector迭代器用法

    #include<iostream> #include<vector> using namespace std; int main() { vector<int> ...

随机推荐

  1. 【Jquery Mobile教程】【问题】- 在页面切换时会闪烁

    用jQuery mobile开发移动应用和web应用的时候,页面切换会闪烁. 感觉,造成这样的原因大概是jQuery mobile在移动浏览器下的性能不佳造成的.jQuery mobile页面切换可以 ...

  2. javap浅析-书籍第3章的手写稿样稿

    转载于:[xieyu_zy](http://blog.csdn.net/xieyuooo/article/details/17452383) 3.2.1javap命令工具 第1章中我们就提到了有些地方 ...

  3. MyPubMedID

    MyPubMedID是北京同舟云信息技术公司全新开发的新一代生物医学文献检索与分析平台. 该平台对PubMed全部内容进行重新清洗.组织.挖掘和开发,在完全消除PubMed检索歧义的同时,能够保证检索 ...

  4. CSS画三角形图标

    /* 等腰三角形(箭头朝上): */ #div1{ width: 0; height: 0; border-bottom: 100px solid cyan; border-left: 50px so ...

  5. C 语言 判断

    if if (im < 0) { im = 60 + im; ih--; } 如果 (im < 0) 小于零,那么 做{ } 中内容 如果 (im < 0) 不小于零,那么 { }中 ...

  6. 2019“嘉韦思杯”3.30初赛一部分Write Up

    同学们TQL.佩服李长兴同学的超神瓜皮思维. 一.飞虎队(希尔密码) 本题是我今天大部分时间的花费处.先百度学习了希尔密码,然后尝试手动计算逆矩阵和矩阵乘法,还求助于线性代数课本,可谓苦不堪言. 做题 ...

  7. Mac系统home目录权限修改【转载】

    转载自:http://ju.outofmemory.cn/entry/283070 最近,想把某程序安装到mac下的/home目录下面,发现没有权限,即便是使用sudo命令也无法创建程序目录,在网上查 ...

  8. Docker 多主机方案

    利用OpenVSwitch构建多主机Docker网络 [编者的话]当你在一台主机上成功运行Docker容器后,信心满满地打算将其扩展到多台主机时,却发现前面的尝试只相当于写了个Hello World的 ...

  9. MFC 读写文件

    写文件: #include<fstream> CStdioFile file; file.Open(_T("parametertable.txt"), CFile::m ...

  10. lvs的负载均衡测试

    近来工作闲暇之余,知道自己的知识欠缺,就在网上找来一些学习视频进行学习,在学习的时候,按照讲课老师的讲解步骤进行配置lvs负载均衡,配置环境如下图: 客户端是我本机的虚拟网卡vmnet8 lvs调度器 ...