本文共 871 字,大约阅读时间需要 2 分钟。
#include #include #include #include #include using namespace std;using std::map;bool check(char c){ if(c>='a'&&c<='z') return true; if(c>='A'&&c<='Z') return true; if(c>='0'&&c<='9') return true; else return false;}map count_;int main(){ string str; getline(cin,str); string word=""; for(int i=0;i ='A'&&str[i]<='Z'){ str[i]+=32; } word+=str[i]; }else{ if(word!=""){ if(count_.find(word)==count_.end()){ count_[word]=1; }else{ count_[word]++; } word=""; } } } if(word!=""){ if(count_.find(word)==count_.end()){ count_[word]=1; }else{ count_[word]++; } } string ans; int MAX=0; for(map ::iterator it=count_.begin();it!=count_.end();it++){ if(it->second>MAX){ MAX=it->second; ans=it->first; } } cout< <<" "< <
转载地址:http://ohxbl.baihongyu.com/