当前位置:网站首页>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;
}边栏推荐
- On the necessity and solution of building a campus online teaching video convergence platform
- 大三,不简单啊!
- Is it safe to open a stock account by mobile phone?
- [chapter 71 of the flutter problem series] mutual conversion between uint8list and image in flutter
- With a monthly salary of 60000 yuan, such people began to be robbed after the Internet "reduced costs and increased efficiency"
- 如何使用伦敦金画出支撑阻力线
- [flutter issues Series title 71] Mutual Conversion between uint8list and Image in flutter
- Summary of time series prediction series (code usage)
- Simple understanding of counting and sorting
- TDD和自动化测试
猜你喜欢

DBNN实验进展

深入虚拟内存(Virtual Memory,VM)

Web API learning notes 1

Deep virtual memory (VM)
![Leetcode 324 swing sort ii[sort double pointer] the leetcode path of heroding](/img/41/b8ba8d771b7224eac1cc8c54fe9d29.png)
Leetcode 324 swing sort ii[sort double pointer] the leetcode path of heroding

k线图基础知识图解——单根K线的含义

2022-06-28: what does the following golang code output? A:true; B:false; C:panic; D: Compilation failed. package main import “fmt“ func main() {

What is the difference between WMS warehouse management system and ERP

Leetcode detailed explanation of stack type

How powerful is the Zadig build? Practice together
随机推荐
云计算的迷路者
Is the account opening of Guosheng securities really safe and reliable
See fengzhixia | FENGZikai, the originator of Guoman, for exclusive sale of Digital Collections
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)
Interpretation of papers (DCN) towards k-means-friendly spaces: simultaneous deep learning and clustering
With the development of industrial Internet as the starting point, the industry can enter a new stage of development
论文解读(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
在线文本过滤小于指定长度工具
[chapter 71 of the flutter problem series] mutual conversion between uint8list and image in flutter
运维排查-使用hcache插件排查Buffer/cache占用过高
深入虚拟内存(Virtual Memory,VM)
Mathematical knowledge: finding combinatorial number I - finding combinatorial number
Go language - reflect
Complex nested object pool (4) -- manage the object pool of multi class instances and multi-stage instances
After crossing, she said that the multiverse really exists
FANUC机器人_KAREL编程入门(2)_通用IO信号的使用方法
[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached
Is it safe to open a stock account online?
Google Earth engine (GEE) -- crop extraction and analysis using sentinel-2 data
Linq连表查询