标签:style blog color 使用 os io div log
11.20 使用insert代替下标操作。
#include<iostream> #include<map> #include<string> #include<utility> using namespace std; int main() { map<string,size_t> word_count; string word; while(cin>>word) { auto ret=word_count.insert({word,1}); if(!ret.second) ++ret.first->second; } auto map_it=word_count.begin(); while(map_it!=word_count.end()) { cout<<map_it->first<<" "<<map_it->second<<endl; ++map_it; } return 0; }
标签:style blog color 使用 os io div log
原文地址:http://www.cnblogs.com/wuchanming/p/3920655.html