当前位置:网站首页>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;
}边栏推荐
- WEB API学习笔记1
- Differences among CPU, GPU, TPU and NPU
- torch. nn. Transformer import failed
- Qtcreater5.15.0 source code compilation process record
- Post-00 cloud native Engineer: use Zadig to increase revenue and reduce expenditure for the R & D of Sichuang Technology (Guangzhou public transport)
- 【Flutter 问题系列第 71 篇】Flutter 中 Uint8List 和 Image 之间的相互转换
- 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
- Sample code of using redis to realize the like function
- 如何结合均线分析伦敦金行情走势线图
- WMS仓库管理系统模块之波次拣货
猜你喜欢

See fengzhixia | FENGZikai, the originator of Guoman, for exclusive sale of Digital Collections

LINQ linked table query

Multiomics single cell data integration and regulatory reasoning based on graph linked embedding

Online text filter less than specified length tool

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

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

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

Wechat red envelope cover making tutorial and use guide with link jump

Linux Installation mysql5.7 (centos7.6) tutorial
oracle设置密码复杂度及设置超时退出的功能
随机推荐
Lecun predicts AgI: big model and reinforcement learning are both ramps! My world model is the new way
全面掌握const的用法《一》
LeCun预言AGI:大模型和强化学习都是斜道!我的世界模型才是新路
go语言插件平台的实现思路
Code example of hiredis
Considerations on the construction of operation and maintenance system - stability
YuMinHong set up two funds funded by his hometown
Realization of 2D code generation in micro build low code
See fengzhixia | FENGZikai, the originator of Guoman, for exclusive sale of Digital Collections
In the era of industrial Internet, the Internet in the traditional sense will evolve into many new forms
Mono's execution process
How to use London gold to draw support resistance line
00 後雲原生工程師:用 Zadig 為思創科技(廣州公交)研發開源節流
【Try to Hack】nmap
Oracle set password complexity and timeout exit function
oracle设置密码复杂度及设置超时退出的功能
一文读懂,WMS仓储管理系统与ERP有什么区别
Fanuc robot_ Introduction to Karel programming (2)_ Usage of general IO signal
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
WMS仓库管理系统模块之波次拣货