美文网首页
B1071 Speech Patterns (two point

B1071 Speech Patterns (two point

作者: Tsukinousag | 来源:发表于2020-02-14 23:30 被阅读0次

B1071 Speech Patterns (25分)

//双指针取单词

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#define lowbit(i)((i)&(-i))
using namespace std;
typedef long long ll;
const int MAX=3e5+10;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
const int SQR=632;//633块,632个
string s;
map<string,int>mp;
bool check(char &str)
{
    if((str>='a'&&str<='z')||(str>='0'&&str<='9'))
        return true;
    else if(str>='A'&&str<='Z')
    {
        str+=32;
        return true;
    }
    return false;
}
int main()
{
    getline(cin,s);
    for(int i=0;i<s.size();i++)
    {
        int j=i;
        string temp="";
        if(check(s[j]))
        {
            while(check(s[j])&&j<s.size())
            {
                temp+=s[j];
                j++;
            }
            mp[temp]++;
            i=j;
        }
    }
    string temp;
    int maxnum=0;
    for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
    {
        if(it->second>maxnum)
        {
            maxnum=it->second;
            temp=it->first;
        }
    }
    cout<<temp<<" "<<maxnum<<endl;
    return 0;
}

相关文章

网友评论

      本文标题:B1071 Speech Patterns (two point

      本文链接:https://www.haomeiwen.com/subject/utmsfhtx.html