当前位置:网站首页>Blue Bridge Cup real problem: word analysis
Blue Bridge Cup real problem: word analysis
2022-07-01 18:22:00 【lsgoose】
Title Description
Xiao Lan is learning a magical language , Words in this language are made up of lowercase English letters become , Some words are long , Far more than the length of normal English words . Xiao Lan has been learning for a long time and can't remember some words , He is not going to memorize these words completely , But to distinguish words according to which letter appears most .
Now? , Please help Xiao Lan , After giving a word , Help him find the letters that appear most and this The number of times a letter appears .
Input description
Enter a line containing one word , Words consist only of lowercase English letters .
For all the evaluation cases , The length of the entered word does not exceed 1000.
Output description
Output two lines , The first line contains an English letter , Indicates which letter appears most in a word individual . If more than one letter appears the same number of times , The one with the smallest output dictionary order .
The second line contains an integer , Indicates the number of times the letter that appears most often appears in the word .
I/o sample
Example 1
Input
lanqiao
Output
a
2
Example 2
Input
longlonglongistoolong
Output
o
6
Operation limit
- Maximum operation time :1s
- Maximum running memory : 256M
#include <iostream>
using namespace std;
int main()
{
// Please enter your code here
int num[26]{0};
string s;
cin>>s;
int max=0;
char c='a';
for(char &ch : s)
{
int index=ch-'a';
num[index]++;
}
for(int i=0;i<26;++i)
{
if(num[i]>max)
{
max=num[i];
c='a'+i;
}
else if(num[i]==max&&'a'+i<c)
{
c='a'+i;
}
}
cout<<c<<endl<<max;
return 0;
}
Here, you should pay attention to which character is selected for the same number of times , Be careful ~
边栏推荐
- Mujoco XML modeling
- Blackwich: the roadmap of decarbonization is the first step to realize the equitable energy transformation in Asia
- MFC obtains local IP (used more in network communication)
- transform. Forward and vector3 Differences in the use of forward
- Nielseniq found that 60% of the re launched products had poor returns
- Android development interview was badly hit in 3 years, and now the recruitment technical requirements are so high?
- Database - MySQL advanced SQL statement (I)
- Penetration practice vulnhub range Keyring
- On the language internationalization of Yongzhong Office
- Countdownlatch blocking wait for multithreading concurrency
猜你喜欢
Data warehouse (3) star model and dimension modeling of data warehouse modeling
Length of learning and changing
ISO 27001 Information Security Management System Certification
Penetration practice vulnhub range Tornado
This is the latest opportunity of the London bank trend
Android development interview was badly hit in 3 years, and now the recruitment technical requirements are so high?
2022 Heilongjiang latest fire protection facility operator simulation test question bank and answers
Mysql database design
PTA year of birth
Flex layout
随机推荐
To improve the efficiency of office collaboration, trackup may be the best choice
Sword finger offer II 105 Maximum area of the island
Mujoco's biped robot Darwin model
Data query language (DQL)
聊聊项目经理最爱使用的工具
Review Net 20th anniversary development and 51aspx growth
开发那些事儿:EasyCVR平台添加播放地址鉴权
期货先锋这个软件正规吗安全吗?选择哪家期货公司更安全?
Cloud computing - make learning easier
Wechat applet blind box - docking wechat payment
Is online stock account opening safe? Is it reliable?
Countdownlatch blocking wait for multithreading concurrency
Source code of new campus errand / campus task platform on mutual station
ArrayList扩容详解
Kia recalls some K3 new energy with potential safety hazards
Irradiance, Joule energy, exercise habits
What are the legal risks of NFT brought by stars such as curry and O'Neill?
Is it safe to open a stock account by mobile phone? What do you need to bring with you to open an account?
Bug of QQ browser article comment: the commentator is wrong
[PHP foundation] realize the connection between PHP and SQL database