标签:找到两个vector里相同的元素(重复的元素只要一个)
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