#include<iostream>
#include<string>
#include<vector>
using std::vector;
using std::string;
using std::cout;
using std::endl;
using std::cin;
int main()
{
vector<int> a{ 1,2,3 };
int b[3];
// use iterator
/*for (auto it = a.begin(); it != a.end(); it++)
{
int i = 0;
b[i] = *it;
cout << b[i] << " ";
}*/
//use subscript
for (decltype(a.size()) i = 0; i != a.size(); i++)
{
b[i] = a[i];
cout << b[i] << " ";
}
return 0;
}
C++ primer 第五版 练习3.42答案
最新推荐文章于 2020-10-29 20:37:54 发布