当前位置:网站首页>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;
}边栏推荐
- Qt5.15中qsrand,srand随机数生成函数已弃用问题
- Ingénieur natif du nuage après 00: utiliser Zadig pour développer des sources ouvertes et des économies d'énergie pour la technologie innovante (bus de Guangzhou)
- Encounter with avita 11: long lost freshness under strong product power
- 计数排序和排序的稳定性
- Fanuc robot_ Introduction to Karel programming (2)_ Usage of general IO signal
- How to use London gold to draw support resistance line
- Basic knowledge diagram of K-line Diagram -- meaning of single K-line
- Online linear programming: Dual convergence, new algorithms, and regret bounds
- 小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现
- 邂逅阿维塔 11:强产品力下久违的新鲜感
猜你喜欢

如何结合均线分析伦敦金行情走势线图
![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

QtCreator5.15.0源码编译全过程记录

如何使用伦敦金画出支撑阻力线

在线文本过滤小于指定长度工具

Go language - reflect

【深度学习】(3) Transformer 中的 Encoder 机制,附Pytorch完整代码
![[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached](/img/cb/d385bee7a229e8d11f5fa8af66311f.gif)
[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached

Considerations on the construction of operation and maintenance system - stability

在QT进行cin(全网最清晰教程)
随机推荐
Differences among CPU, GPU, TPU and NPU
【深度学习】(3) Transformer 中的 Encoder 机制,附Pytorch完整代码
Redis+aop+ user defined annotation to realize flow restriction
直击产业落地 | 飞桨重磅推出业界首个模型选型工具
Business atlas in super factory
k线图基础知识图解——单根K线的含义
老家出资,俞敏洪设立两支基金
00 後雲原生工程師:用 Zadig 為思創科技(廣州公交)研發開源節流
【kotlin】好看的弹出框、自定义弹出框(对话框)、扩展函数、菊花等待条、消息提示框
keil工程,程序写多后,RTT不能打印
【网关开发】ngx嵌套lua时处理CIDR表示的IP地址段
Prometeus 2.36.0 新特性
【Try to Hack】nmap
Pytorch builds transformer to realize multivariable and multi step time series forecasting (load forecasting)
What is the difference between WMS warehouse management system and ERP
Is it safe to open a stock account online?
Steady! How thousands of micro services can quickly access Zadig (helm chart)
国盛证券开户是真的安全可靠吗
稳!上千微服务如何快速接入 Zadig(Helm Chart 篇)
Post-00 cloud native Engineer: use Zadig to increase revenue and reduce expenditure for the R & D of Sichuang Technology (Guangzhou public transport)