0
因此,我有一个程序读取文件,并通过使用std::map
并将int
作为关键字和std::vector
作为值来获取最大单词。我需要打印出最大的单词,但在排序时遇到问题。而输出应该是版权,出版,通用,蓝图 我得到:蓝图,版权,通用,出版使用大写和小写字母排序向量
我该如何解决这个问题?矢量不是大写还是小写? 这是我到目前为止有:
string temp;
stringstream ss(line);
while(ss >> temp) {
int wordlength = temp.length();
wordit = wordbycount.find(wordlength);
if (wordit != wordbycount.end()) {
vector<string> arrayofLongest = wordit->second;
std::vector<string>::iterator iterator1 = find(arrayofLongest.begin(), arrayofLongest.end(), temp);
if (iterator1 == arrayofLongest.end()) {
wordit->second.push_back(temp);
}
}
else {
wordbycount[wordlength] = temp;
}
}
你可能会考虑再添加一行来调用你的向量的std :: sort()。 –