博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT A1071
阅读量:6885 次
发布时间:2019-06-27

本文共 871 字,大约阅读时间需要 2 分钟。

clipboard.png

唯一要注意的是当读入字符串进行有效字符截取的时候,队尾可能还会有有效字符,记得在循环结束的时候进行word的判别;

#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/

你可能感兴趣的文章
一位前辈的经验,给正在思考的自己
查看>>
分享一篇关于lucene原理的文章
查看>>
基于 HTML5 结合互联网+ 的 3D 隧道
查看>>
Win10下 80端口被system(pid=4)占用的解决方法
查看>>
使用SubVersion+TortoiseSVN多仓库方式进行版本控制
查看>>
Nginx虚拟目录alias和root目录
查看>>
MySQL(Extends)
查看>>
Android KeyboardView实现App内置键盘开发
查看>>
Python文件夹复制
查看>>
细谈 vue 核心- vdom 篇
查看>>
ajax+springmvc实现跨域请求
查看>>
SaltStack快速入门-配置管理
查看>>
批处理研究(QQ绿化和卸载)
查看>>
对比农行与建行网银业务办理流程
查看>>
Oracle 11G RAC 安装图示(一)
查看>>
【xpghost】xp系统启动后迟延问题如何解决
查看>>
浅谈ElasticSearch的嵌套存储模型
查看>>
离开外包又一段时间了
查看>>
aapt 解析android apk
查看>>
Layout Inflation不能这么用
查看>>