【C++学习】迭代器的使用:vector的操作---ShinePans
来源:互联网 发布:创维云电视软件下载 编辑:程序博客网 时间:2024/06/06 02:01
/*迭代器的使用:xx.begin();xx.end();begin()指向第一个元素,end指向最后一个元素的下一个元素.auto it=xx.begin(); *it为该元素的引用; (*it).empty();判断it所指向的字符串是否为空;*/#include <iostream>#include <string>#include <cctype>#include <vector>using namespace std;int main(){int sum;vector<int> ints;int temp;cout << "输入一些数:" << endl;while (cin >> temp)ints.push_back(temp);auto beg = ints.begin(), end = ints.end();auto mid = ints.begin() + (end - beg) / 2;for (auto it = ints.begin(); it != mid; ++it){sum = (*it) + (*(end - 1));end--;cout << sum << endl;}system("pause");return 0;}
使用了容器
5 0
- 【C++学习】迭代器的使用:vector的操作---ShinePans
- 【C++学习】vector的使用,输入小写,输出大写---ShinePans
- [c++的运用]-使用迭代器,vector指针统计分数---ShinePans
- 【C++学习】vector的使用,输入一串数字,输出相邻和---ShinePans
- C#-StringBuilder类的使用---ShinePans
- C#-正则表达式的使用---ShinePans
- C++vector的使用总结及常用vector操作
- C#-控制台-Char类的使用大全---ShinePans
- c-大量经典的c算法---ShinePans
- C++----Vector的使用
- C#-记录打开过的文件---ShinePans
- mysqlWorkBench的使用,表的创建---shinepans
- 【C++学习】-字符串的比较---ShinePans
- 【C++学习】-字符串的遍历---ShinePans
- [C++] C++ Vector 的使用
- C++Vector的使用误区
- C++Vector的使用误区
- c++Vector的使用误区
- ss
- UI组件缩放和旋转
- UiButton操作
- Android相机拍照后在系统gallery中看不到的解决办法
- one-to-one双向关联之加载
- 【C++学习】迭代器的使用:vector的操作---ShinePans
- uml 9种图之序列图
- XMLPULL解析(2)---通过对象序列化生成XML文档
- tomcat的一些设置
- fckeditor编辑器的使用
- 程序员必看的那些电影
- MySQL Vs PostgreSQL 2
- Python系列视频教程: Django【13讲】第五讲 URL配置
- POJ 2486 经典树形dp