1071. Speech Patterns (25)
来源:互联网 发布:管家婆软件工贸版 编辑:程序博客网 时间:2024/06/05 18:59
#include<iostream>#include<map>#include<string>using namespace std;bool check(char c){if((c>='0'&&c<='9')||(c>='a'&&c<='z')||(c>='A'&&c<='Z')) return true;else return false;}char change(char c){if(c>='A'&&c<='Z') return c-'A'+'a'; else return c;} int main(){map<string,int> count;string str;getline(cin,str);int i=0;while(i<str.length()){string word;while(i<str.length()&&check(str[i])==true){str[i]=change(str[i]);word+=str[i];i++;}if(word!=""){//单词非空 if(count.find(word)==count.end()){ count[word]=1; } else{ count[word]++; }}while(i<str.length()&&check(str[i])==false){i++;} }int maxcount=0;string maxword;for(map<string,int>::iterator it=count.begin();it!=count.end();it++){if(it->second>maxcount){maxword=it->first;maxcount=it->second;}}cout<<maxword<<" "<<maxcount<<endl;}
0 0
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- java file文件类操作使用方法大全
- c语言
- 温习java编程思想
- fedora文本模式启动
- Sierra下编译Aosp
- 1071. Speech Patterns (25)
- HashMap源码分析
- jquery实现元素不确定时,如何确定宽度 && inline-block
- 1100. Mars Numbers (20)
- 工科数学分析-微积分(1)
- HDU 4348 To the moon 【主席树+区间修改】
- bitmap算法
- 《思考的技术》(1)
- HashMap线程安全问题