首页 > 其他 > 详细

找到两个vector里相同的元素(重复的元素只要一个)

时间:2015-04-11 06:39:54      阅读:190      评论:0      收藏:0      [点我收藏+]
std::vector<int> findSame(const std::vector<int> &nLeft,const std::vector<int> &nRight)
{
	std::vector<int> nResult;
	for (std::vector<int>::const_iterator nIterator = nLeft.begin(); nIterator != nLeft.end(); nIterator++)
	{
		if(std::find(nRight.begin(),nRight.end(),*nIterator) != nRight.end())
			nResult.push_back(*nIterator);
	}

	return nResult;
}


找到两个vector里相同的元素(重复的元素只要一个)

原文:http://wwhx27.blog.51cto.com/6807550/1631096

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!