#include<cstdio>#include<iostream>#include<string>#include<string.h>#include<algorithm>#include<queue>#include<map>#include<set>using namespace std;bool judge(char a){ if((a>='0'&&a<='9')||(a>='a'&&a<='z')||(a>='A'&&a<='Z')) return false; else return true;}int main(){ //freopen("input.txt","r",stdin); string str; string temp; string out; int maxnum=0; map<string,int> m; getline(cin,str); bool flag; for(int i=0;i<str.size();i++) { flag=judge(str[i]); if(flag==false) { if((str[i]>='A'&&str[i]<='Z')) { str[i]=str[i]-'A'+'a'; temp+=str[i]; } else temp+=str[i]; } else { if(temp.size()!=0) { if(m.find(temp)==m.end()) m[temp]=1; else m[temp]++; if(m[temp]>maxnum) { maxnum=m[temp]; out=temp; } else if(m[temp]==maxnum&&temp<out) out=temp; } temp.clear(); } } if(temp.size()!=0) { if(m.find(temp)==m.end()) m[temp]=1; else m[temp]++; if(m[temp]>maxnum) { maxnum=m[temp]; out=temp; } else if(m[temp]==maxnum&&temp<out) out=temp; } temp.clear(); cout<<out<<" "<<m[out]; //freopen("con","r",stdin); system("pause"); return 0;}
新闻热点
疑难解答