PAT (Advanced Level) 1071. Speech Patterns (25)
简单题。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std; char s[+];
string ans[+];
int tot; bool g(char c)
{
if(c>='a'&&c<='z') return ;
if(c>=''&&c<='') return ;
if(c>='A'&&c<='Z') return ;
return ;
} int main()
{
gets(s);
for(int i=;s[i];i++)
if(s[i]>='A'&&s[i]<='Z') s[i]=s[i]-'A'+'a';
string f=""; tot=;
for(int i=;s[i];i++)
{
if(g(s[i])) f=f+s[i];
else
{
if(f=="") continue;
ans[tot++]=f;
f="";
}
}
if(f!="") ans[tot++]=f;
sort(ans,ans+tot);
int now=,pre=;
string out;
int num=; while()
{
if(ans[now]==ans[pre]) now++;
else
{
if(now-pre>num)
{
num=now-pre;
out=ans[pre];
}
pre=now;
}
if(pre==tot) break;
} cout<<out<<" "<<num<<endl;
return ;
}
PAT (Advanced Level) 1071. Speech Patterns (25)的更多相关文章
- 【PAT甲级】1071 Speech Patterns (25 分)(getline(cin,x))
题意: 输入一行字符串,输出出现过次数最多的由字母和数字组成的字符串以及它出现的次数(对大小写不敏感,输出全部输出小写). AAAAAccepted code: #define HAVE_STRUCT ...
- PAT 甲级 1071 Speech Patterns (25 分)(map)
1071 Speech Patterns (25 分) People often have a preference among synonyms of the same word. For ex ...
- PAT Advanced 1071 Speech Patterns (25 分)
People often have a preference among synonyms of the same word. For example, some may prefer "t ...
- PAT甲题题解-1071. Speech Patterns (25)-找出现最多的单词
分割字符串的用法+map映射给出input中出现次数最多的单词,如果次数相同,给出按字典序最小的. 这里我用了自定义分隔符来读取字符串,方法如下: //按照定义的分隔符d来分割字符串,对str进行读取 ...
- 1071. Speech Patterns (25)
People often have a preference among synonyms of the same word. For example, some may prefer "t ...
- 1071 Speech Patterns (25)(25 分)
People often have a preference among synonyms of the same word. For example, some may prefer "t ...
- PAT (Advanced Level) 1114. Family Property (25)
简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- PAT (Advanced Level) 1109. Group Photo (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- PAT (Advanced Level) 1105. Spiral Matrix (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...
随机推荐
- Golang: pprof
压测的时候,如果在应用包里加入runtime包,会对压测产生非常严重的干扰. 测试1:开启runtime包 [luwenwei@test-weishi01v ~]$ siege -c --time=1 ...
- Global事件执行顺序
Global.asax 文件,有时候叫做 ASP.NET 应用程序文件,提供了一种在一个中心位置响应应用程序级或模块级事件的方法.你可以使用这个文件实现应用程序安全性以及其它一些任务.下面让我们详细看 ...
- Ubuntu 网管服务器配置
1.设置Linux内核支持ip数据包的转发 echo "1" > /proc/sys/net/ipv4/ip_forward or vi /etc/sysctl.conf ...
- Linux 系统监控
*lsof 列出打开的文件 常用 lsof -i:8080*htop进程监控iotop(bugs)iptraf实时局域网IP监控psacct 监视用户活动monit Linux进程和服务监控工具* ...
- CentOS7 PostgreSQL 安装
PostgreSQL安装 安装使用yum安装 (找源 http://yum.postgresql.org/) yum install https://download.postgresql.org/p ...
- iOS本地推送与远程推送详解
一.简介 分为本地推送和远程推送2种.可以在应用没有打开甚至手机锁屏情况下给用户以提示.它们都需要注册,注册后系统会弹出提示框(如下图)提示用户是否同意,如果同意则正常使用:如果用户不同意则下次打开程 ...
- Java学习笔记之一
1.对大小写敏感 2.class,类是构建所有Java应用程序和applet的构建块,Java应用程序中的全部内容都必须放置在类中. 3.类名,没有长度限制,必须以字母开头,可以使字母.数字.下划线的 ...
- springMVC中ajax的运用于注意事项
ajax的运用: 注意事项: dataType:"json"在ajax中可写可不写(ajax能够自动识别返回值类型),写了更加规范,可以在ajax识别错误返回值类型的时候,指定返回 ...
- 在MyEclipse中运行tomcat报错 严重: Error starting static Resources
严重: Error starting static Resourcesjava.lang.IllegalArgumentException: Document base E:\apache-tomca ...
- ibatis 自动生成map,bean,dao
1.下载 AbatorForEclipse1.1.0 地址:http://download.csdn.net/detail/fym548/9426877 点击Archive按钮选择下载的,然后重启My ...