当前位置:网站首页>++cnt1[s1.charAt(i) - ‘a‘];
++cnt1[s1.charAt(i) - ‘a‘];
2022-07-24 05:20:00 【一枚小可爱c】
++cnt1[s1.charAt(i) - 'a'];其中String s1
s1.charAt(i)返回字符串s1的第i个字符。
假设字符串s1仅包含小写字母(比如从'a'到'z'),s1.charAt(i) - 'a'返回的是字符a的index 0,b index 1,等等(z index25)
++cnt1[s1.charAt(i) - 'a'];//使与字符s1.charAt(i)对应的计数器加1。
因此,这个循环for (int i = 0; i < n; ++i) {++cnt1[s1.charAt(i) - 'a']; }计算字符串s1中每个字母出现的次数。
最后,一个cn1[0]将包含'a'的个数,一个cn1[1]将包含'b'的个数,以此类推。
边栏推荐
- 统计信号处理小作业——瑞利分布噪声中确定性直流信号的检测
- 达梦数据库_触发器、视图、物化视图、序列、同义词、自增列、外部链接等基本的操作
- Erp+rpa opens up the enterprise information island, and the enterprise benefits are doubled
- Are you still trying to limit MySQL paging?
- 多商户商城系统功能拆解05讲-平台端商家主营类目
- 【activiti】activiti入门
- 达梦数据库_常用的用户管理命令
- [vSphere high availability] host failover
- Flink sql-client.sh use
- Authorized access to MySQL database
猜你喜欢

多商户商城系统功能拆解09讲-平台端商品品牌

关于卷积神经网络中的“输入通道”和“输出通道”的概念

达梦数据库_逻辑架构基础

多商户商城系统功能拆解13讲-平台端会员管理

The SaaS mall system of likeshop single merchant is built, and the code is open source without encryption.

对接CRM系统和效果类广告,助力企业精准营销助力企业精准营销

【mycat】mycat搭建读写分离

Introduction to PC mall module of e-commerce system

Logical structure of Oracle Database

达梦数据库_LENGTH_IN_CHAR和CHARSET的影响情况
随机推荐
The method of using bat command to quickly create system restore point
多商户商城系统功能拆解05讲-平台端商家主营类目
Wechat applet returns parameters or trigger events
plsql查询数据乱码
Flink sql-client.sh使用
How to quickly recover data after MySQL misoperation
使用bat命令快速创建系统还原点的方法
Multi merchant mall system function disassembly lecture 09 - platform end commodity brands
ThreadLocal stores the current login user information
达梦数据库_逻辑架构基础
自己的一点点小想法——使用MATLAB实现类似环形缓冲器的读取
Logical structure of Oracle Database
Multi merchant mall system function disassembly lecture 07 - platform side commodity management
[vSphere high availability] host failover
[Baidu map API] the version of the map JS API you are using is too low and no longer maintained. In order to ensure the normal use of the basic functions of the map, please upgrade to the latest versi
【mycat】mycat配置文件
《统计学习方法(第2版)》李航 第22章 无监督学习方法总结 思维导图笔记
[activiti] activiti introduction
ERP+RPA 打通企业信息孤岛,企业效益加倍提升
Whole station downloader recommendation