第三章 3.21
来源:互联网 发布:诺基亚软件下载塞班 编辑:程序博客网 时间:2024/05/11 03:59
请使用迭代器重做3.3.3节的第一个练习
3.16:编写一段程序,把练习3.13中vector对象的容量和具体内容输出出来。
3.13
(a)vector<int> v1;
(b)vector<int> v2(10);
(c)vector<int> v3;(10,42);
(d)vector<int> v4{10};
(e)vector<int> v5{10,42};
(f)vector<string> v6{10};
(g)vector<string> v7{10,"hi"};
#include <iostream>#include <vector>#include <string>#include <cctype>using namespace std;int main(){ vector<int> v1;vector<int> v2(10);vector<int> v3;(10,42);vector<int> v4{10};vector<int> v5{10,42};vector<string> v6{10};vector<string> v7{10,"hi"};cout << "v1.size:" << v1.size() << endl;cout << "v2.size:" << v2.size() << endl;cout << "v3.size:" << v3.size() << endl;cout << "v4.size:" << v4.size() << endl;cout << "v5.size:" << v5.size() << endl;cout << "v6.size:" << v6.size() << endl;cout << "v7.size:" << v7.size() << endl;for(auto it = v1.begin(); it != v1.end(); ++it){cout << *it << " ";}cout << endl;for(auto it = v2.begin(); it != v2.end(); ++it){cout << *it << " ";}cout << endl;for(auto it = v3.begin(); it != v3.end(); ++it){cout << *it << " ";}cout << endl;for(auto it = v4.begin(); it != v4.end(); ++it){cout << *it << " ";}cout << endl;for(auto it = v5.begin(); it != v5.end(); ++it){cout << *it << " ";}cout << endl;for(auto it = v6.begin(); it != v6.end() && !it->empty(); ++it){cout << *it << " ";}cout << endl;for(auto it = v7.begin(); it != v7.end() && !it->empty(); ++it){cout << *it << " ";}return 0;}
0 0
- 第三章 3.21
- 第三章第三题
- 第三章第三题
- 第三章第三题
- 第三章
- 第三章
- 第三章
- 第三章
- 第三章
- 第三章
- 第三章
- 《第三章》
- 第三章
- 第三章
- 第三章
- 第三章
- 第三章
- 第三章
- hdu4568Hunter(最短路+TSP)
- 本地service【Android】
- 测试驱动开发实践 - Test-Driven Development
- 关于回调的一个最简单的Demo
- 根据 *_train_test.prototxt文件生成 *_deploy.prototxt文件
- 第三章 3.21
- Android和Java面试题搜集整理
- Spring学习笔记-1:SpringMVC hello world
- 在C++中使用引用类型的成员变量
- Android xml绘图 (三)-----------Layer
- leetcode 33. Search in Rotated Sorted Array
- &、&&和|、||的区别
- <Learning Transferable Features with Deep Adaptation Networks>caffe 添加MMDLoss层(caffe 自定义网络层)
- 51Nod-1097-拼成最小的数