【基础算法】双指针专题


3581. 单词识别

#include 
#include 
#include 
#include 

using namespace std;

int main()
{
    string str;
    getline(cin, str);

    map hash;
    for(int i = 0; i < str.size(); i ++ )
    {
        if(isalpha(str[i]))
        {
            int j = i;
            string word;
            while(j < str.size() && isalpha(str[j]))
                word += tolower(str[j ++ ]);
            hash[word] ++ ;
            i = j - 1;
        }
    }

    for(auto &c : hash)
    {
        cout << c.first << ':' << c.second << endl;
    }
    return 0;
}

作者:Once.
链接:https://www.acwing.com/activity/content/code/content/3106636/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。