【PAT甲级】1071 Speech Patterns (25 分)(getline(cin,x))
题意:
输入一行字符串,输出出现过次数最多的由字母和数字组成的字符串以及它出现的次数(对大小写不敏感,输出全部输出小写)。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
string word;
map<string,int>mp;
string s;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string x;
getline(cin,x);
int n=x.size();
for(int i=;i<n;++i)
if((x[i]>='A'&&x[i]<='Z')||(x[i]>='a'&&x[i]<='z')||(x[i]>=''&&x[i]<='')){
if(x[i]>='A'&&x[i]<='Z')
x[i]=x[i]-'A'+'a';
word.push_back(x[i]);
}
else if(word!=""){
++mp[word];
word.clear();
}
if(word!=""){
++mp[word];
word.clear();
}
int mx=;
for(auto it:mp)
if(it.second>mx){
mx=it.second;
s=it.first;
}
cout<<s<<" "<<mx;
return ;
}
【PAT甲级】1071 Speech Patterns (25 分)(getline(cin,x))的更多相关文章
- 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 ...
- 1071 Speech Patterns (25)(25 分)
People often have a preference among synonyms of the same word. For example, some may prefer "t ...
- PAT甲级——A1071 Speech Patterns
People often have a preference among synonyms of the same word. For example, some may prefer "t ...
- PAT 甲级 1020 Tree Traversals (25分)(后序中序链表建树,求层序)***重点复习
1020 Tree Traversals (25分) Suppose that all the keys in a binary tree are distinct positive intege ...
- PAT 甲级 1146 Topological Order (25 分)(拓扑较简单,保存入度数和出度的节点即可)
1146 Topological Order (25 分) This is a problem given in the Graduate Entrance Exam in 2018: Which ...
- PAT 甲级 1063 Set Similarity (25 分) (新学,set的使用,printf 输出%,要%%)
1063 Set Similarity (25 分) Given two sets of integers, the similarity of the sets is defined to be ...
- PAT 甲级 1059 Prime Factors (25 分) ((新学)快速质因数分解,注意1=1)
1059 Prime Factors (25 分) Given any positive integer N, you are supposed to find all of its prime ...
- PAT 甲级 1051 Pop Sequence (25 分)(模拟栈,较简单)
1051 Pop Sequence (25 分) Given a stack which can keep M numbers at most. Push N numbers in the ord ...
随机推荐
- cadence动态铜皮的参数设置
注意这幅图和上一幅图那个焊盘距离shape的间距,变大了,这个设置很用的.
- 集成unittest做接口测试
unittest接口测试 上篇已经讲了接口测试的做法,利用的是postman工具,工具始终是工具,它有一定的局限性,比如测试数据的存放,断言的方法以及上下接口关联使用灵活性.python对http接口 ...
- HTML 5的革新——语义化标签(一)
HTML 5的革新之一:语义化标签一节元素标签. 在HTML 5出来之前,我们用div来表示页面章节,但是这些div都没有实际意义.(即使我们用css样式的id和class形容这块内容的意义).这些标 ...
- yii2 场景使用
场景定义 //场景 const SCENARIO_USER_CREATE='0';//前台用户新增 const SCENARIO_USER_UPDATE='1';//前台用户更新 场景配置 publi ...
- ASP.NET + MVC5 入门完整教程三 (下) ---MVC 松耦合
建立松耦合组件 MVC 模式最重要的特性之一视他支持关注分离,希望应用程序中的组件尽可能独立,只有很少的几个可控依赖项.在理想的情况下,每个组件都不了解其他组件,而只是通过抽象接口来处理应用程序的其他 ...
- 【译】通过 Rust 学习解析器组合器 — Part 1
原文地址:Learning Parser Combinators With Rust 原文作者:Bodil 译文出自:掘金翻译计划 本文永久链接:https://github.com/xitu/gol ...
- LTE引理——解决数论竞赛题的利器
LTE (Lifting The Exponent Lemma)引理是一个解指数型不定方程的强力工具.它在Olympiad folklore非常知名,虽然它的起源已经无从查找了.它和Hensel’s ...
- while、for循环结构_python
一.while循环的基础例子: 例子1:判断是否大于50 例子2:按需打印乘法口诀 例子3:无限循环 while True: print (“true”) 二.for循环 1.for循环的常见范围的用 ...
- AAC huffman decoding
在AAC编码器内部,使用huffman coding用于进一步减少scalefactor和量化频谱系数的冗余. 从individual_channel_stream层提取码流进行huffman解码,码 ...
- 杭电oj初体验之 Code
PLA算法: https://blog.csdn.net/red_stone1/article/details/70866527 The problem: Analysis: 题目链接可见:https ...