zoukankan      html  css  js  c++  java
  • insert例子

    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;
    }
  • 相关阅读:
    实验四
    密码破解技术
    222
    111
    6
    5
    4
    第三次
    第二次
    第一次
  • 原文地址:https://www.cnblogs.com/wuchanming/p/3920655.html
Copyright © 2011-2022 走看看