#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. Last Work-随机出题加法游戏

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  2. postgresql清理工具

    1. 每个DB都单独进行了vacuumdb的命令: vacuumdb -d mydb -z -v 2. full vacuum : vacuumdb -a  -f -z -v  .  自动vacuum ...

  3. 我的第一个flutter程序

    环境搭建好了之后,终于可以开始flutter的学习,废话少说先开始‘Hello World’. 创建好flutter项目之后,打开设备模拟器 打开之后 准备ok,开始编码 -------------- ...

  4. Java Base64位加密和解密(包括其他加密参考)

    链接https://blog.csdn.net/longguangfu8/article/details/78948213 常用加密解密算法[RSA.AES.DES.MD5]介绍和使用 https:/ ...

  5. Redis的过期策略和内存淘汰策略

    Redis的过期策略:通常有三种,Redis中同时使用惰性过期和定期过期两种过期策略组合. 定时过期:每个设置过期时间的key都需要创建一个定时器,到过期时间就会立即清除.该策略可以立即清除过期的数据 ...

  6. !!!常用bootstrap代码

    http://v3.bootcss.com/components/  组件 http://v3.bootcss.com/customize/  bootstrap定制 http://v3.bootcs ...

  7. py库:os、shutil、pathlib

    https://www.cnblogs.com/MnCu8261/p/5494807.html shutil模块 http://blog.csdn.net/rozol/article/details/ ...

  8. mysql查看及设置最大连接数

    #查看: show variables like '%max_connections%'; #设置: set GLOBAL max_connections = 1000;

  9. 移动端常用UI框架

    作为一个前端人员来说,总结几款相对来说不错的用于移动端开发的UI框架是非常必要的,以下几种移动端UI框架就能基本满足工作中开发需要,根据项目需求,选用合适的框架搭建项目,更能容易提高开发效率. 一.M ...

  10. SpringCloud系列九:SpringCloudConfig 基础配置(SpringCloudConfig 的基本概念、配置 SpringCloudConfig 服务端、抓取配置文件信息、客户端使用 SpringCloudConfig 进行配置、单仓库目录匹配、应用仓库自动选择、仓库匹配模式)

    1.概念:SpringCloudConfig 基础配置 2.具体内容 通过名词就可以发现,SpringCloudConfig 核心作用一定就在于进行配置文件的管理上.也就是说为了更好的进行所有微服务的 ...