找到两个vector里相同的元素(重复的元素只要一个)
时间:2015-04-11 06:39:54
收藏:0
阅读:190
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; }
原文:http://wwhx27.blog.51cto.com/6807550/1631096
评论(0)