C++ 提高教程 STL -容器算法迭代器初识

 

 1 第一种遍历方式

	vector<int>::iterator itBegin = v.begin(); //起始迭代器,指向容器中的第一个元素
	vector<int>::iterator itEnd = v.end();//结束迭代器 指向容器中最后一个元素的下一个位置
	//第一种遍历方式:
	while (itBegin != itEnd)
	{
		
		cout << *itBegin << endl;
		itBegin++;
	}

 2 第二种遍历方式

	for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
	{
		cout << *it <&l
全部评论

相关推荐

迷茫的大四🐶:都收获五个了,兄弟那还说啥,不用改了,去玩吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务