当前位置:网站首页>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;
}
边栏推荐
- TF-A中的工具介绍
- [转]:Apache Felix Framework配置属性
- 剑指 Offer 09. 用两个栈实现队列
- Development error notes
- Zzulioj 1673: b: clever characters???
- 使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
- 剑指 Offer 53 - I. 在排序数组中查找数字 I
- Haut OJ 1347: addition of choice -- high progress addition
- Es module and commonjs learning notes
- lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
猜你喜欢
To be continued] [UE4 notes] L4 object editing
[to be continued] [UE4 notes] L2 interface introduction
质量体系建设之路的分分合合
The present is a gift from heaven -- a film review of the journey of the soul
[merge array] 88 merge two ordered arrays
浅谈JVM(面试常考)
sync.Mutex源码解读
[转]MySQL操作实战(三):表联结
Generate filled text and pictures
剑指 Offer 05. 替换空格
随机推荐
JVM call not used once in ten years
剑指 Offer 53 - II. 0~n-1中缺失的数字
Haut OJ 2021 freshmen week II reflection summary
[转]:Apache Felix Framework配置属性
What is the agile proportion of PMP Exam? Dispel doubts
Generate filled text and pictures
SAP-修改系统表数据的方法
剑指 Offer 09. 用两个栈实现队列
To the distance we have been looking for -- film review of "flying house journey"
浅谈JVM(面试常考)
Programmers' experience of delivering takeout
Embedded database development programming (VI) -- C API
小程序直播+電商,想做新零售電商就用它吧!
Add level control and logger level control of Solon logging plug-in
Haut OJ 1350: choice sends candy
[allocation problem] 455 Distribute cookies
[to be continued] [UE4 notes] L2 interface introduction
[speed pointer] 142 circular linked list II
使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
[转]MySQL操作实战(三):表联结