当前位置:网站首页>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;
}
边栏推荐
- Pointnet++学习
- 软件测试 -- 0 序
- 远程升级怕截胡?详解FOTA安全升级
- Haut OJ 1401: praise energy
- 数仓项目的集群脚本
- Warning using room database: schema export directory is not provided to the annotation processor so we cannot export
- kubeadm系列-02-kubelet的配置和启动
- 对象的序列化
- Bubble sort summary
- lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
猜你喜欢
SAP method of modifying system table data
Use of snippets in vscode (code template)
[to be continued] [UE4 notes] L2 interface introduction
[to be continued] [UE4 notes] L3 import resources and project migration
利用HashMap实现简单缓存
Embedded database development programming (zero)
Quick sort summary
Improvement of pointnet++
远程升级怕截胡?详解FOTA安全升级
[turn]: OSGi specification in simple terms
随机推荐
xftp7与xshell7下载(官网)
kubeadm系列-02-kubelet的配置和启动
支持多模多态 GBase 8c数据库持续创新重磅升级
ssh免密登录设置及使用脚本进行ssh登录并执行指令
剑指 Offer 53 - I. 在排序数组中查找数字 I
TF-A中的工具介绍
Insert sort
剑指 Offer 05. 替换空格
使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
[es practice] use the native realm security mode on es
Bucket sort
发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
Haut OJ 1243: simple mathematical problems
[interval problem] 435 Non overlapping interval
剑指 Offer 09. 用两个栈实现队列
The present is a gift from heaven -- a film review of the journey of the soul
Haut OJ 1357: lunch question (I) -- high precision multiplication
SAP-修改系统表数据的方法
[轉]: OSGI規範 深入淺出
Acwing 4301. Truncated sequence