안녕하세요, 저는 벡터에서 고유 한 요소를 가져 오는이 함수를 가지고 있지만 어떻게 고유 요소 수를 얻을 수 있는지 궁금합니다.C++ 고유 요소 수
void getUniqueSellers(vector<string> & result) {
vector<CService>::iterator i= m_vData.begin();
while(i != m_vData.end()) {
if(find(result.begin(), result.end(), (*i).GetSeller()) == result.end()) {
result.push_back((*i).GetSeller());
}
i++;
}
}
void main()
{
vector<string> res;
myAnalyzer.getUniqueSellers(res);
vector<string>::iterator i=res.begin();
while(i!=res.end()) {
cout<< *i<<",";
i++;
}
system("pause");
return;
}
'무효 main' 법적 서명이 없습니다. – chris
고유 번호 또는 고유 번호의 총 수를 각각 얼마나 많이 나타 냈습니까? – taocp
std :: sort 및 std :: unique 또는 고유 요소 만 삽입하는 std :: set에 삽입합니다. 거기에서 크기 또는 모든 고유 한 요소를 얻을 수 있습니다. – dchhetri