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 ...
随机推荐
- STM32 一通道单次转换
之前弄过ADC连续转换,还配了DMA传输,项目上不希望这样做,因为有其他设备用到DMA传输,就会不停的抢占优先级,效率低. 按照需求改成ADC单次转换,非连续,用的时候只需调下函数执行一次转换即可. ...
- gets()
C: #include <stdio.h> //这个头文件包含gets()函数,这个函数在ISO/IEC 9899 2011(C11)标准中被移除 int main(void) { ...
- 第13章 Swing程序设计
1.Swing概述 GUI(图形用户界面)为程序提供图形界面,最初的设计目的是为程序员构建一个通用的GUI,使其能够在所有平台上运行.但Java 1.0中基础类AWT(抽象窗口工具箱)并没有达到这个要 ...
- 老鸟需要知道的一些php系统类函数
作为一个老手级别的php程序员,知道下面几个php系统级别的函数,不足为多吧!获取系统信息和调试程序的时候应该能用的上! PHP系统类函数 assert函数:检查assertion声明是否错误 ext ...
- MySQL 的实时性能监控利器【转】
操作系统及MySQL数据库的实时性能状态数据尤为重要,特别是在有性能抖动的时候,这些实时的性能数据可以快速帮助你定位系统或MySQL数据库的性能瓶颈,就像你在Linux系统上使用「top,sar,io ...
- Apache开启gzip压缩传输
修改Apache配置文件 第一步,添加两个模块 LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module m ...
- no ia32-libs
sudo apt-get install lib32stdc++6 sudo apt-get install lib32z1 http://blog.csdn.net/wangbin_jxust/ar ...
- Spring 读取XML配置文件的两种方式
import org.springframework.context.ApplicationContext; import org.springframework.context.support.Cl ...
- wpf之数据触发器DataTrigger
wpf, 根据绑定的属性的值的不同(数据分类),界面上显示不同的控件(绑定不同类型的属性),可以使用数据库触发器DataTrigger实现这一功能. 实现的效果如下: 首先建立实体类: 更改通知类: ...
- Java中获取路径的方法_自我分析
就目前的我来说最常用的两种获取路径的方法是 class.getRecource(filename) 和 class.getclassloader.getRecource(filename) 这两者的 ...