int main(int argc,char **argv) {
map<string, size_t> word_count;
set<string> exclude = { "and","or","but","the" };
string word;
ifstream in("ss.txt");
while (in >> word) {
*word.begin() = tolower(*word.begin());
if (ispunct(*word.rbegin()))
word.pop_back();
++word_count[word];
}
for (const auto &w : word_count)
cout << w.first << " occurs " <<w.second<< (w.second > 1 ? " times." : " time.") << endl;
}
C++Primer 练习11.4
猜你喜欢
转载自blog.csdn.net/dididisailor/article/details/82828153
今日推荐
周排行