当前位置:网站首页>C语言-单词分析解析
C语言-单词分析解析
2022-06-28 23:02:00 【王陈锋】
题目描述
小蓝正在学习一门神奇的语言,这门语言中的单词都是由小写英文字母组 成,有些单词很长,远远超过正常英文单词的长度。小蓝学了很长时间也记不住一些单词,他准备不再完全记忆这些单词,而是根据单词中哪个字母出现得最多来分辨单词。
现在,请你帮助小蓝,给了一个单词后,帮助他找到出现最多的字母和这 个字母出现的次数。
输入描述
输入一行包含一个单词,单词只由小写英文字母组成。
对于所有的评测用例,输入的单词长度不超过 1000。
输出描述
输出两行,第一行包含一个英文字母,表示单词中出现得最多的字母是哪 个。如果有多个字母出现的次数相等,输出字典序最小的那个。
第二行包含一个整数,表示出现得最多的那个字母在单词中出现的次数。
输入输出样例
示例 1
输入
lanqiao
输出
a
2
示例 2
输入
longlonglongistoolong
输出
o
6
#include <stdio.h>
#include <stdlib.h>
int read(char *str);
int main(int argc, char *argv[])
{
// 请在此输入您的代码
char str[1000];
scanf("%s",str);
read(str);
return 0;
}
int read(char *str)
{
int i=0,j=0,max=0,max1=0;
char zimu[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int count[26]={0};
for(i=0;i<26;i++){
for(j=0;str[j]!='\0';j++){
if(zimu[i]==str[j])
count[i]++;
}
}
for(i=0;i<26;i++)
{
if(count[i]>max)
{
max=count[i];
max1=i;
}
}
printf("%c\n",zimu[max1]);
printf("%d",max);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
// 请在此输入您的代码
int count[26]={0},max=0,i;
char ch;
while((ch=getchar())!='\n')
count[ch-'a']++;
for(i=1;i<26;i++)
if(count[i]>count[max])
max=i;
printf("%c\n%d",max+'a',count[max]);
return 0;
}边栏推荐
- 自媒体行业内卷严重:企业自媒体应该何去何从
- 非科班!自学之路!
- Is it safe to open a stock account by mobile phone?
- Pytorch builds transformer to realize multivariable and multi step time series forecasting (load forecasting)
- 【Flutter 问题系列第 71 篇】Flutter 中 Uint8List 和 Image 之间的相互转换
- Embedded dynamic Arabic string conversion LCD display string [thanks for Jianguo ambition]
- Sample code of using redis to realize the like function
- After crossing, she said that the multiverse really exists
- Undefined symbol main (referred from entry9a.o).
- A password error occurred when docker downloaded the MySQL image to create a database link
猜你喜欢

One card can sell tens of millions, and the business expansion is faster than that of players: you don't understand the Jianghu of star cards

leetCode-栈类型详解
oracle设置密码复杂度及设置超时退出的功能

How to use London gold to draw support resistance line

一张能卖上千万,商家扩张比玩家还快:球星卡的江湖你不懂

Deep virtual memory (VM)

【Word 教程系列第 2 篇】Word 中如何设置每页的表格都有表头

Leetcode detailed explanation of stack type

Multiomics single cell data integration and regulatory reasoning based on graph linked embedding
![Leetcode 324 Swing sort II [tri double pointeur] le chemin du leetcode pour l'héroding](/img/41/b8ba8d771b7224eac1cc8c54fe9d29.png)
Leetcode 324 Swing sort II [tri double pointeur] le chemin du leetcode pour l'héroding
随机推荐
两栏布局左边图片显示部分由右边内容高度决定
SqlServer复习
Is it safe and reliable for changtou school to help open a securities account? How to drive
Advanced workplace | understand the "entry" of position advantages
一文搞懂shell脚本
On the necessity and solution of building a campus online teaching video convergence platform
LeetCode 324 摆动排序 II[排序 双指针] HERODING的LeetCode之路
Oracle deleting archived logs and adding scheduled tasks
flowable 边界定时器
Powerful open source API interface visual management platform Yapi
leetCode-栈类型详解
小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现
生产环境sonarqube安装
Leetcode 324 swing sort ii[sort double pointer] the leetcode path of heroding
Lost in cloud computing
题解 洛谷P1762 偶数/6.21校内考试T2
Wave picking of WMS warehouse management system module
Considerations on the construction of operation and maintenance system - stability
Prometeus 2.36.0 新特性
DBNN实验进展