0 Star 0 Fork 0

BingBox / Cpp-Primer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ex9_13.cpp 807 Bytes
一键复制 编辑 原始数据 按行查看 历史
// @author @shbling @Yue Wang
//
// Exercise 9.13:
// How would you initialize a vector<double> from a list<int>?
// From a vector<int>?
// Write code to check your answers.
//
#include <iostream>
#include <string>
#include <vector>
#include <list>
using std::list; using std::vector; using std::cout; using std::endl;
int main()
{
list<int> ilst(5, 4);
vector<int> ivc(5, 5);
// from list<int> to vector<double>
vector<double> dvc(ilst.begin(), ilst.end());
for (auto i : ilst) cout << i << " ";
cout << endl;
for (auto d : dvc) cout << d << " ";
cout << endl;
// from vector<int> to vector<double>
vector<double> dvc2(ivc.begin(), ivc.end());
for (auto i : ivc) cout << i << " ";
cout << endl;
for (auto d : dvc2) cout << d << " ";
return 0;
}
C++
1
https://gitee.com/Lv80/Cpp-Primer.git
git@gitee.com:Lv80/Cpp-Primer.git
Lv80
Cpp-Primer
Cpp-Primer
master

搜索帮助