本文部分内容参考于这儿

vector 的基础知识,上文已经阐述地很详尽了。笔者谨给出 vector 的声明及其常用函数。

  1. 代码抬头需包含
#include<vector>
using namespace std;
  1. 定义一个存储 int 类型的 vector 类型 c
vector<int> c;
  1. 常用的 vector 函数如下表
vector<int> c;
语句 意义
c.push_back(a) a 压入 c 的末尾
c.pop_back() 弹出 c 的末尾元素
c.pop() 弹出 c 的首个元素
c.size() 返回 c 的长度
c.empty() 判断 c 是否为空
c.clear() 清空 c
c.erase(pos) 移除 pos 处的元素
c.erase(begin,end) 移除 [begin,end) 的元素

最新文章

  1. MFC-01-Chapter01:Hello,MFC---1.1 Windows 编程模型
  2. Django 创建APP简单步骤
  3. VC++ 判断文件或文件夹是否存在的快捷方法 _access
  4. Idea_编译报错 javacTask: 源发行版 1.6 需要目标发行版 1.6
  5. 第二章 Background &amp; Borders 之 Multiple borders
  6. Virtual member call in a constructor
  7. Implementing Remote Validation in MVC
  8. Gilde加载网络图片(一)
  9. 10.30 afternoon
  10. centos 下使用sublime
  11. 表单界面的兼容PC手机端解决方案
  12. Centos7搭建Confluence破解版
  13. UNIX网络编程——进程间通信概述
  14. 点击a标签实现txt文件另存的效果
  15. 统计每日单量MySQL语句
  16. Mysql SQL优化系列之——执行计划连接方式浅释
  17. 【LibreOJ】#6395. 「THUPC2018」城市地铁规划 / City 背包DP+Prufer序
  18. git detached
  19. 1、Python快速入门(0529)
  20. 【POJ】4007.Flood-it!

热门文章

  1. python函数练习
  2. Ubuntu16.4安装Vivado Design Suite sdx2019.1
  3. Java第二次作业第一题
  4. NestedInteger Java
  5. [Leetcode][动态规划] 零钱兑换
  6. 关于瀑布流的布局原理分析(纯CSS瀑布流与JS瀑布流)
  7. 在vue中使用[provide/inject]实现页面reload
  8. 【SQL server初级】SQL Server 2005 实现数据库同步备份 过程--结果---分析
  9. POJ 2386——Lake Counting(DFS)
  10. python爬虫——简易天气爬取