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 ...
随机推荐
- WKWebView与Js交互
首先打开webstorm,将最下面h5拷贝到html中.然后导入工程 #define kMessageHandlerName @"mymobile" 1.创建配置类 - (WKWe ...
- echo json数据给ajax后, 需要加上exit,防止往下执行,带上其他数据,到时ajax失败
01返回json数据给ajax后需要加上exit.返回json数据前不能有其他输出 function apply(){ if(IS_POST){$info['status'] = 1; echo js ...
- POJ- Find a multiple -(抽屉原理)
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6452 Accepted: 2809 Special Judge D ...
- ios做的两个矩形相交叉
#import "ViewController.h" @interface ViewController (){ UIView *_gee; //定义的实例变量 UI ...
- jq插件开发总结
http://www.cnblogs.com/silverLee/archive/2009/12/22/1629925.html jQuery插件的开发包括两种: 一种是类级别的插件开发,即给jQue ...
- 全选js实现
前端全选框 <input type='checkbox' name='allSelect' onclick='sel(this)'></input> //有i个选择框 < ...
- spring securiy使用总结
我们常见的几个功能: 注册后直接登录,并且remember-me这种在网上找到很多注册后登录的,但是remember-me没有.其实解决方案还是看源码比较方便.a. 装载authenticationM ...
- Windows 系统变量大全
来源:http://blog.csdn.net/kingwolf_javascript/article/details/2477234 %ALLUSERSPROFILE% : 列出所有用户Profil ...
- runtime——消息机制
本文授权转载,作者:Sindri的小巢(简书) 从异常说起 我们都知道,在iOS中存在这么一个通用类类型id,它可以用来表示任何对象的类型 —— 这意味着我们使用id类型的对象调用任何一个方法,编译器 ...
- 转 sort按照数据大小排序
一般默认的sort都是按照字母的ASCII进行排序的,现在想按照数字的大小进行排序 这里有一个文件test,内容为: 8723 23423 321324 213432 23 234 ...