huangmingchuan / Cpp_Primer_Answers

《C++ Primer》第五版中文版习题答案

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

练习3.23未使用题目要求的迭代器要求

LeoTao777 opened this issue · comments

练习要求使用迭代器将vector中的整数变为两倍,作者使用的是范围for循环。
我的程序代码如下,如有问题还请作者提出。谢谢!
#include
#include
using namespace std;

int main(void)
{

vector<int> s(10,42);
for (auto i = s.begin(); i != s.end(); i++)
{
	*i = 2 * (*i);
	cout << *i << ", ";
}

cout << endl;
system("pause");
return 0;

}