当前位置:网站首页>Maximum number of "balloons"
Maximum number of "balloons"
2022-07-05 05:27:00 【low dog】
Their thinking
First, we will count the variables of each letter , Let me create a variable for the final output ( That is, and all the minimum values , That is to say Number of whole words ), Then scan the input , adopt switch The function counts each letter on a line , Finally, after processing the counted variables , Compare the rows and assign the minimum value to the variable to be returned .
All the code
int nums(char* text){
int b,a,l,o,n;
int min=0;
while(*text){
switch(*text){
case 'b':b++;break;
case 'a':a++;break;
case 'l':l++;break;
case 'o':o++;break;
case 'n':n++;break;
}
*text++;
}
l/=2;
o/=2;
min=b<a?b:a;
min=min<l?min:l;
min=min<o?min:o;
min=min<n?min:n;
return min;
}
边栏推荐
- Heap sort summary
- Haut OJ 1401: praise energy
- To be continued] [UE4 notes] L4 object editing
- [转]: OSGI规范 深入浅出
- 动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
- Optimization scheme of win10 virtual machine cluster
- [binary search] 69 Square root of X
- Use of room database
- Embedded database development programming (V) -- DQL
- [merge array] 88 merge two ordered arrays
猜你喜欢
Heap sort summary
浅谈JVM(面试常考)
[turn to] MySQL operation practice (III): table connection
Research on the value of background repeat of background tiling
Using HashMap to realize simple cache
sync.Mutex源码解读
Learning notes of "hands on learning in depth"
[interval problem] 435 Non overlapping interval
Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
Yolov5 adds attention mechanism
随机推荐
Talking about JVM (frequent interview)
Solon 框架如何方便获取每个请求的响应时间?
[turn]: OSGi specification in simple terms
[turn to] MySQL operation practice (I): Keywords & functions
[转]: OSGI规范 深入浅出
动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
Binary search basis
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
[turn]: Apache Felix framework configuration properties
用STM32点个灯
Find a good teaching video for Solon framework test (Solon, lightweight application development framework)
National teacher qualification examination in the first half of 2022
远程升级怕截胡?详解FOTA安全升级
Programmers' experience of delivering takeout
Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
[es practice] use the native realm security mode on es
Drawing dynamic 3D circle with pure C language
[turn to] MySQL operation practice (III): table connection
读者写者模型
Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!