当前位置:网站首页>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 ~
边栏推荐
- ArrayList扩容详解
- Smart factory digital management system software platform
- The latest intelligent factory MES management system software solution
- Mujoco's biped robot Darwin model
- 证券开户安全么,有没有什么样的危险呢
- How to retrieve the password for opening Excel files
- Gameframework eating guide
- February 16, 2022 Daily: graph neural network self training method under distribution and migration
- New patent applications and transfers
- At present, where is the most formal and safe account opening for futures speculation? How to open a futures account?
猜你喜欢
Oracle TRUNC function processing date format
Data query language (DQL)
Intelligent operation and maintenance practice: banking business process and single transaction tracking
The difference and relationship between iteratible objects, iterators and generators
Explain in detail the process of realizing Chinese text classification by CNN
transform. Forward and vector3 Differences in the use of forward
Yuancosmos game farmersworld farmers world - core content of the second conference in China!
ISO 27001 Information Security Management System Certification
Common design parameters of solid rocket motor
Thinkphp6 - CMS multi wechat management system source code
随机推荐
PTA year of birth
MFC obtains local IP (used more in network communication)
手机开户股票开户安全吗?那么开户需要带些什么?
Highly reliable program storage and startup control system based on anti fuse FPGA and QSPI flash
ArrayList扩容详解
At present, where is the most formal and safe account opening for futures speculation? How to open a futures account?
ZABBIX alarm execute remote command
540. Single element in ordered array
D @ safety and dip1000
Cloud picture says | distributed transaction management DTM: the little helper behind "buy buy buy"
Intel's open source deep learning tool library openvino will increase cooperation with local software and hardware parties and continue to open
How to retrieve the password for opening Excel files
The method of real-time tracking the current price of London Silver
Rotation order and universal lock of unity panel
Extract the compressed package file and retrieve the password
The difference and relationship between iteratible objects, iterators and generators
LeetCode 148. Sort linked list
Yuancosmos game farmersworld farmers world - core content of the second conference in China!
Can hero sports go public against the wind?
Fix the black screen caused by iPhone system failure