std::vector<int>& delRepeat(std::vector<int>& nVector) { std::set<int> nTemp(nVector.begin(),nVector.end()); nVector.clear(); for (std::set<int>::iterator nIterator = nTemp.begin();nIterator != nTemp.end();nIterator++) nVector.push_back(*nIterator); return nVector; }
std::vector<int>& delRepeat(std::vector<int>& nVector) { std::vector<int> nTemp(nVector.begin(),nVector.end()); nVector.clear(); for (std::vector<int>::iterator nIterator = nTemp.begin();nIterator != nTemp.end();nIterator++) { if(std::find(nVector.begin(),nVector.end(),*nIterator) != nVector.end()) nVector.push_back(*nIterator); } return nVector; }
时间: 2024-10-10 04:49:55