当前位置:网站首页>C language - word analysis
C language - word analysis
2022-06-28 23:03:00 【Wangchenfeng】
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
#include <stdio.h>
#include <stdlib.h>
int read(char *str);
int main(int argc, char *argv[])
{
// Please enter your code here
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[])
{
// Please enter your code here
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;
}边栏推荐
- Implementation of go language plug-in platform
- WEB API学习笔记1
- Leetcode 324 Swing sort II [tri double pointeur] le chemin du leetcode pour l'héroding
- Linux Installation mysql5.7 (centos7.6) tutorial
- Undefined symbol main (referred from entry9a.o).
- Panxiaoming, senior vice president of IC nansha|amd and President of Greater China: process, architecture and platform optimization break through the computing boundary
- 在QT进行cin(全网最清晰教程)
- 如何结合均线分析伦敦金行情走势线图
- Simple understanding of counting and sorting
- [deep learning] (3) encoder mechanism in transformer, complete pytoch code attached
猜你喜欢

Online sql to htmltable tool

强大的开源API接口可视化管理平台-YApi
![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
![[Chapter 2 of word tutorial series] how to set the table on each page to have a header in word](/img/1a/8416d2c48bf1ddcc45e0c5d9acf242.png)
[Chapter 2 of word tutorial series] how to set the table on each page to have a header in word

A password error occurred when docker downloaded the MySQL image to create a database link

全面掌握const的用法《一》

邂逅阿维塔 11:强产品力下久违的新鲜感

Zadig + cave Iast: let safety dissolve in continuous delivery

This simple little function saves 213 hours for our production research team in half a year

深入虚拟内存(Virtual Memory,VM)
随机推荐
Prometeus 2.36.0 new features
Oracle删除归档日志及添加定时任务
Oracle set password complexity and timeout exit function
Is it safe and reliable for changtou school to help open a securities account? How to drive
TDD和自动化测试
Summary of time series prediction series (code usage)
Flowable boundary timer
直击产业落地 | 飞桨重磅推出业界首个模型选型工具
自媒体行业内卷严重:企业自媒体应该何去何从
flowable 边界定时器
After crossing, she said that the multiverse really exists
利用Redis实现点赞功能的示例代码
Zadig + cave Iast: let safety dissolve in continuous delivery
Business atlas in super factory
Fanuc robot_ Introduction to Karel programming (2)_ Usage of general IO signal
The love digital smart 2022 summit opens, sharing data strategy and building data-driven organization methodology
How to solve the problem of desktop without sound
DBNN实验进展
Production environment sonarqube installation
2022-06-28:以下golang代码输出什么?A:true;B:false;C:panic;D:编译失败。 package main import “fm