当前位置:网站首页>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;
}
边栏推荐
- [to be continued] [UE4 notes] L2 interface introduction
- [interval problem] 435 Non overlapping interval
- National teacher qualification examination in the first half of 2022
- SSH password free login settings and use scripts to SSH login and execute instructions
- JVM call not used once in ten years
- [speed pointer] 142 circular linked list II
- 2022上半年全国教师资格证下
- Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
- Count sort
- Bubble sort summary
猜你喜欢
Romance of programmers on Valentine's Day
sync. Interpretation of mutex source code
剑指 Offer 09. 用两个栈实现队列
[interval problem] 435 Non overlapping interval
TF-A中的工具介绍
剑指 Offer 35.复杂链表的复制
远程升级怕截胡?详解FOTA安全升级
Talking about JVM (frequent interview)
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
SAP-修改系统表数据的方法
随机推荐
YOLOv5添加注意力機制
Reflection summary of Haut OJ freshmen on Wednesday
Yolov5 adds attention mechanism
Shell Sort
Optimization scheme of win10 virtual machine cluster
Chapter 6 data flow modeling - after class exercises
Binary search basis
Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
Use of room database
On-off and on-off of quality system construction
Solon Logging 插件的添加器级别控制和日志器的级别控制
kubeadm系列-01-preflight究竟有多少check
Drawing dynamic 3D circle with pure C language
Romance of programmers on Valentine's Day
[binary search] 34 Find the first and last positions of elements in a sorted array
Es module and commonjs learning notes -- ESM and CJS used in nodejs
Insert sort
对象的序列化
[interval problem] 435 Non overlapping interval
Use of snippets in vscode (code template)