#include <string>
#include <iostream>
#include <vector>
#include <algorithm> using namespace std; int main()
{
vector<int> fi;
cout<<fi.size()<<endl;
//输出0 vector<int> se(6,20);
cout<<se.size()<<endl;
//输出6 for(vector<int>::iterator it = se.begin(); it<se.end(); it++)
{
cout << " " << *it;
}
cout << endl;
//输出20 20 20 20 20 20 vector<int> th(se.begin()+2,se.end());
cout<<se.size()<<endl; for(vector<int>::iterator it = th.begin(); it<th.end(); it++)
{
cout << " " << *it;
}
cout << endl;
//输出20 20 20 20 vector<char> str(10,'A'); //初始化为包含10个'A'字符的数组
str.push_back('B'); // 现在str有11个字符
str.push_back('C'); // 现在str有12个字符
printf("%c",str[0]); //输出A
printf("%c",str[9]); //输出A
printf("%c",str[10]); //输出B
printf("%c",str[11]); //输出C return 0;
}

  

C++ vector 实例的更多相关文章

  1. c++ vector实例

    #include <iostream> #include <string> #include <vector> #include <iostream> ...

  2. C++ vector 实例二

    // constructing vectors #include <iostream> #include <vector> int main () { // construct ...

  3. Flex Vector使用(转)

    从前(Flex SDK 4.0 以前版本)创建 Vector 实例一定要如下所示,这样的语法使我们在构造 Vector 对象时无法指定元素: var v:Vector.<T> = new ...

  4. JDK1.8源码阅读系列之三:Vector

    本篇随笔主要描述的是我阅读 Vector 源码期间的对于 Vector 的一些实现上的个人理解,用于个人备忘,有不对的地方,请指出- 先来看一下 Vector 的继承图: 可以看出,Vector 的直 ...

  5. java集合系列——List集合之Vector介绍(四)

    1. Vector的简介 JDK1.7.0_79版本 Vector 类可以实现可增长的对象数组.与数组一样,它包含可以使用整数索引进行访问的组件.但是,Vector 的大小可以根据需要增大或缩小,以适 ...

  6. Vector容器构造函数

    No1 vector(); No2 vector( const vector& c ); No3 explicit vector( size_type num, const TYPE& ...

  7. java之vector详细介绍

    1 vector介绍 Vector简介 Vector 是矢量队列,它是JDK1.0版本添加的类.继承于AbstractList,实现了List, RandomAccess, Cloneable这些接口 ...

  8. AS3.0 Vector的运用

    使用Vector类编程 一个array(数组)就像是把一套变量组织在一起的容器.单个数组可以含有许多不同的值.你可以储存和取得数组中的单个值(也就是数组elements(元素)).你也可以通过直接操作 ...

  9. C++中vector小学习,顺便查了下<stdio.h>(或<cstdio>)

    今天看书,邻桌在看<C++ Primer>,拿过来看了一会儿.以前比较少用vector容器,看了下后,瞬间觉得好腻害的样子,就想试一下.嗯,就是试一下而已.(代码可能网上都差不多,有参考) ...

随机推荐

  1. CentOS安装MySQL,(常规安装方式MySQL无法远程连接)

    转载自:https://blog.csdn.net/z13615480737/article/details/78906598 CentOS7默认数据库是mariadb, 但是 好多用的都是mysql ...

  2. Spring Cloud(3):Ribbon的使用

    基于搭建好的Eureka Server+Eureka Client:https://www.cnblogs.com/xuyiqing/p/10861541.html 有了服务,那么现在学习如何调用服务 ...

  3. thymeleaf 模板语言简介

    参考网址: https://blog.csdn.net/mlin_123/article/details/51816533 1.1 Thymeleaf 在有网络和无网络的环境下皆可运行,而且完全不需启 ...

  4. php 实现格式化数字功能

    php 实现数字格式化功能 /** * @param $num 数字 * @param int $decimal 精度 * @param int $point_len 分隔位长度 * @return ...

  5. Apache Solr-6.0.1 (OpenLogic CentOS 7.2)

    Apache Solr-6.0.1 (OpenLogic CentOS 7.2) 平台: CentOS 类型: 虚拟机镜像 软件包: java1.8 solr6.0.1 application ser ...

  6. 新增自定义聚合函数StrJoin

    1.添加程序集Microsoft.SqlServer.Types CREATE ASSEMBLY [Microsoft.SqlServer.Types] AUTHORIZATION [sys] FRO ...

  7. js中(break,continue,return)的区别

    break 一般用于跳出整个循环(for,while) continue  跳出本次循环,进入下一次循环 return 只能出现在函数体内,一旦执行return,后面的代码将不会执行,经常用retur ...

  8. hdu-1272 小希的迷宫---并查集或者DFS

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1272 题目大意: Problem Description 上次Gardon的迷宫城堡小希玩了很久(见 ...

  9. 2017.12.25 Linux系统的使用

    Linux系统的使用 现在标配的系统是 Linux + Nginx + PHP + MySQL ,这样的配置越来越多的大公司在用的了说到配置不同的是一个公司的规约,比如说挂载一般分为2个盘, / 下面 ...

  10. 使用vue-cli创建项目

    使用Vue UI创建.管理项目 1.全局安装vue-cli 3.0 npm install -g @vue/cli 2.启动vue ui 创建项目: vue ui