#include <bits/stdc++.h>
using namespace std;
bool check(char c)//检查是否为字母或数字
{
if(c>='A'&&c<='Z'||c>='a'&&c<='z'||c>='0'&&c<='9')
return true;
else
return false;
}
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]))
{
if(str[i]>='A'&&str[i]<='Z'){ //大写统一改为小写
str[i] += ('a'-'A');
}
word += str[i]; //字符拼接 +
i++;
}
if(word != ""){
if(count.find(word)==count.end()) count[word]=1; //这单词还没出现过,计数为1
else count[word]++;
}
while(i<str.length()&&!check(str[i])) //遇到其它字符跳过
{
i++;
}
}
string ans;
int MAX=0;
for(map<string,int>::iterator it=count.begin();it != count.end();it++) //只能用!=,而不能用<end()
{
if(it->second>MAX)
{
ans = it->first;
MAX = it->second;
}
}
cout<<ans<<" "<<MAX<<endl;
return 0; }

  

PATA 1071 Speech Patterns.的更多相关文章

  1. PAT 1071 Speech Patterns[一般]

    1071 Speech Patterns (25 分) People often have a preference among synonyms of the same word. For exam ...

  2. PAT 甲级 1071 Speech Patterns (25 分)(map)

    1071 Speech Patterns (25 分)   People often have a preference among synonyms of the same word. For ex ...

  3. 1071 Speech Patterns——PAT甲级真题

    1071 Speech Patterns People often have a preference among synonyms of the same word. For example, so ...

  4. 1071. Speech Patterns (25)

    People often have a preference among synonyms of the same word. For example, some may prefer "t ...

  5. 1071 Speech Patterns

    People often have a preference among synonyms of the same word. For example, some may prefer "t ...

  6. 1071 Speech Patterns (25)(25 分)

    People often have a preference among synonyms of the same word. For example, some may prefer "t ...

  7. PAT Advanced 1071 Speech Patterns (25 分)

    People often have a preference among synonyms of the same word. For example, some may prefer "t ...

  8. PAT (Advanced Level) 1071. Speech Patterns (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  9. PAT甲题题解-1071. Speech Patterns (25)-找出现最多的单词

    分割字符串的用法+map映射给出input中出现次数最多的单词,如果次数相同,给出按字典序最小的. 这里我用了自定义分隔符来读取字符串,方法如下: //按照定义的分隔符d来分割字符串,对str进行读取 ...

随机推荐

  1. ISO/IEC 27001 信息安全管理体系认证

    一. 信息安全管理体系标准业务介绍 1. 背景介绍 信息作为组织的重要资产,需要得到妥善保护.但随着信息技术的高速发展,特别是Internet的问世及网上交易的启用,许多信息安全的问题也纷纷出现:系统 ...

  2. python_matplotlib cannot import name _thread on mac

    最后的2行错误信息是 from six.moves import _thread ImportError: cannot import name _thread 1 2 发现是six出现了问题,用pi ...

  3. jquery.cookie.js用法详解

    创建一个会话cookie: $.cookie(‘cookieName’,'cookieValue’); 注:当没有指明cookie时间时,所创建的cookie有效期默认到用户浏览器关闭止,故被称为会话 ...

  4. WPF控件获得焦点时去除虚线框

    原文:WPF控件获得焦点时去除虚线框 <Setter Property="FocusVisualStyle" Value="{x:Null}" />

  5. 高性能mysql笔记 第一章 mysql架构

    1.1  mysql逻辑结构 第一层: 负责连接处理,授权认证,安全等事情 第二层:负责mysql的大部分核心功能 ,查询解析,分析,优化,缓存和所有的内置函数,所有跨存储引擎的功能都在这一层实现,, ...

  6. 一个由单例模式在多线程环境下引发的 bug

    问题症状 HTTP 日志系统,老是出现日志信息覆盖的情况.比如同时调用 A 接口和 B 接口,B 接口请求响应信息变成了 A 接口请求响应相关信息.这个问题在并发量大的情况下越来越严重. 问题初步分析 ...

  7. HBuilder打包App流程记录

    摘要:基于HBuilder建立一个简单的移动app项目,并打包成apk,使用这套平台用H5开发真正的移动项目,相当于省去了原生部分的人力和工作配合,性能的话,后续我会基于这套技术开发相关的应用来验证, ...

  8. ztree的树形结构不能正常显示原因

    1.ztree树形结构不能正常显示情况如下: 2.原因之一:未给其类添加 ztree 原因二:未引用ztree的css样式 <link href="~/Content/CSS/zTre ...

  9. Qt for windows消息循环、libqxt分析和wince快捷键处理

    Qt for windows消息循环.libqxt分析和wince快捷键处理 利用Qt做windows图形界面开发和MFC相比,个人感觉还是比较简单好用的:首先利用Designer工具搞个ui文件:然 ...

  10. Android零基础入门第71节:CardView简单实现卡片式布局

    还记得我们一共学过了多少UI控件了吗?都掌握的怎么样啊. 安卓中一些常用控件学习得差不多了,今天再来学习一个新的控件CardView,在实际开发中也有非常高的地位. 一.CardView简介 Card ...