STL vector的使用(三)遍历
2015-08-25 09:09
232 查看
一. vector的遍历总类:
1. 未用名字空间,使用vector 进行遍历:
2. 使用名字空间,使用vector进行遍历:
3. 利用迭代器,对vector进行遍历:
1. 未用名字空间,使用vector 进行遍历:
for(std::vector<std::string>::size_type index = 0; index < vect.size();index++) { std::cout << vect[index] << std::endl; }
2. 使用名字空间,使用vector进行遍历:
for(int index = 0; index < vect.size();index++) { cout << vect[index] << endl; }
3. 利用迭代器,对vector进行遍历:
vector<string>::iterator it = vect.begin(); for(;it != vect.end();it++) { cout << *it << endl; }
相关文章推荐
- 152. Maximum Product Subarray
- 理解ECMAScript的几个关键语句
- c#中的delegate(委托)和event(事件)
- C++中的常量定义小结
- 解开Android应用程序组件Activity的"singleTask"之谜
- Android 网络通信框架Volley简介
- 日经社説 20150825 年金機構と厚労省は責任感と緊張感を
- c++ 头文件中定义函数的优缺点
- 自动收集awr报告
- 前端学习笔记
- Python集合(set)类型的操作
- dev view 列名称居中
- easyui datagrid 批量编辑和提交
- ETL kettle 自学总结
- 数据仓库建模:浅析一致性维度
- eclipse导入一个项目之后没有JRE System Library怎么办?
- mysql安装图解 mysql图文安装教程(详细说明)
- SSi框架整合
- 【编程之美】寻找数组中的最大值和最小值
- 源码推荐(8.25):简单易用的Toast,实现水位波浪动画