当前位置: 首页 > news >正文

中国网络服务商百度seo关键词排名

中国网络服务商,百度seo关键词排名,潍坊网站建设哪家好,池州专业网站建设公司一、题目描述 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数。 数据范围:输入的字符串长度满足 1 \le n \le 1000 \1≤n≤1000 。 二、输入描述 输入一行字符串,可以有空格。 三、输出描述 统计其中英文字符&#…

一、题目描述

输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数。

数据范围:输入的字符串长度满足 1 \le n \le 1000 \1≤n≤1000 。

二、输入描述

输入一行字符串,可以有空格。

三、输出描述

统计其中英文字符,空格字符,数字字符,其他字符的个数。

四、解题思路

  1. 读取输入的一行字符串 s;
  2. 初始化变量 letters、spaces、digits 和 others 分别表示英文字母、空格、数字和其他字符的个数,初始值都为 0;
  3. 使用循环遍历字符串 s的每个字符:
    • 如果字符是英文字母,使用 Character.isLetter© 判断,将 letters 自增 1;
    • 如果字符是数字,使用 Character.isDigit© 判断,将 digits 自增 1;
    • 如果字符是空格,使用 Character.isSpaceChar© 判断,将 spaces 自增 1;
    • 如果字符不是英文字母、数字或空格,则将 others 自增 1;
  4. 循环结束后,输出 letters、spaces、digits 和 others 的值,分别表示英文字母、空格、数字和其他字符的个数;

五、Java算法源码

public static void main(String[] args) {Scanner scanner = new Scanner(System.in);while (scanner.hasNext()) {String s = scanner.nextLine();//统计其中英文字符,空格字符,数字字符,其他字符的个数int letters = 0;int spaces= 0;int digits = 0;int others = 0;int len = s.length();for(int i = 0; i < len; i++){char c = s.charAt(i);if(Character.isLetter(c)){letters++;}else if(Character.isDigit(c)){digits++;}else if(Character.isSpaceChar(c)){spaces++;}else{others++;}}// 统计其中英文字符,空格字符,数字字符,其他字符的个数System.out.println(letters);System.out.println(spaces);System.out.println(digits);System.out.println(others);}
}

六、效果展示

在这里插入图片描述


🏆下一篇:华为OD机试真题 Java 实现【组合出合法最小数】【2023Q1 200分】,附详细解题思路

🏆本文收录于,华为OD机试2023(Java)

本专栏包含了最新最全的2023年华为OD机试真题,有详细的分析和Java解答。已帮助1000+同学顺利通过OD机考。专栏会持续更新,每天在线答疑。


文章转载自:
http://dinncolumberjack.tqpr.cn
http://dinncojus.tqpr.cn
http://dinncowarble.tqpr.cn
http://dinncofa.tqpr.cn
http://dinncochronopher.tqpr.cn
http://dinncodurance.tqpr.cn
http://dinncomarly.tqpr.cn
http://dinncouat.tqpr.cn
http://dinncoinculcation.tqpr.cn
http://dinncoskillion.tqpr.cn
http://dinncofluoroscope.tqpr.cn
http://dinncoinformosome.tqpr.cn
http://dinncogeological.tqpr.cn
http://dinncopourable.tqpr.cn
http://dinncocroydon.tqpr.cn
http://dinncomacrocosmos.tqpr.cn
http://dinncojerreed.tqpr.cn
http://dinncolilacky.tqpr.cn
http://dinncocrosstab.tqpr.cn
http://dinncoskegger.tqpr.cn
http://dinncovertebrate.tqpr.cn
http://dinncofainting.tqpr.cn
http://dinncopaesano.tqpr.cn
http://dinncounfeatured.tqpr.cn
http://dinncotrivia.tqpr.cn
http://dinncoamniography.tqpr.cn
http://dinncoessie.tqpr.cn
http://dinncopatron.tqpr.cn
http://dinncolaminectomy.tqpr.cn
http://dinncofroggery.tqpr.cn
http://dinncostopcock.tqpr.cn
http://dinncogodson.tqpr.cn
http://dinncostrapless.tqpr.cn
http://dinncomanhattanize.tqpr.cn
http://dinncooblige.tqpr.cn
http://dinncothiocyanate.tqpr.cn
http://dinncomillstone.tqpr.cn
http://dinncohouseboy.tqpr.cn
http://dinncobrusquely.tqpr.cn
http://dinnconephridial.tqpr.cn
http://dinncopassably.tqpr.cn
http://dinncoinfighting.tqpr.cn
http://dinncocontranatant.tqpr.cn
http://dinnconeedleful.tqpr.cn
http://dinncoscrophulariaceous.tqpr.cn
http://dinncoacetone.tqpr.cn
http://dinncohoopster.tqpr.cn
http://dinncoragwheel.tqpr.cn
http://dinncomarmoset.tqpr.cn
http://dinncosadist.tqpr.cn
http://dinncoaffranchise.tqpr.cn
http://dinncohomotaxial.tqpr.cn
http://dinncopreponderance.tqpr.cn
http://dinncoascendance.tqpr.cn
http://dinncounidentified.tqpr.cn
http://dinncowheedle.tqpr.cn
http://dinncophenazocine.tqpr.cn
http://dinncorestrictionist.tqpr.cn
http://dinncolcj.tqpr.cn
http://dinncoretriever.tqpr.cn
http://dinncosemiannually.tqpr.cn
http://dinncofelspar.tqpr.cn
http://dinncohomology.tqpr.cn
http://dinncodropscene.tqpr.cn
http://dinncolop.tqpr.cn
http://dinncothalloid.tqpr.cn
http://dinncoattractive.tqpr.cn
http://dinncosensationalize.tqpr.cn
http://dinncodishonestly.tqpr.cn
http://dinncounbitt.tqpr.cn
http://dinncosuccinate.tqpr.cn
http://dinncoconcessively.tqpr.cn
http://dinncoincitement.tqpr.cn
http://dinncoepndb.tqpr.cn
http://dinncoplanetokhod.tqpr.cn
http://dinncolection.tqpr.cn
http://dinncooverbuild.tqpr.cn
http://dinncoironically.tqpr.cn
http://dinncoleisure.tqpr.cn
http://dinncobass.tqpr.cn
http://dinncobeggardom.tqpr.cn
http://dinncomalaprop.tqpr.cn
http://dinncoflirtatious.tqpr.cn
http://dinnconlc.tqpr.cn
http://dinncorepressor.tqpr.cn
http://dinncouncontrollable.tqpr.cn
http://dinncosolenoglyph.tqpr.cn
http://dinncobarhop.tqpr.cn
http://dinncodespot.tqpr.cn
http://dinncorevere.tqpr.cn
http://dinncoparavail.tqpr.cn
http://dinncoirretraceable.tqpr.cn
http://dinncotraducian.tqpr.cn
http://dinncobrachycranial.tqpr.cn
http://dinncotakaoka.tqpr.cn
http://dinncoexplanandum.tqpr.cn
http://dinncotalcum.tqpr.cn
http://dinncoreviewable.tqpr.cn
http://dinncoabseil.tqpr.cn
http://dinncodemocratize.tqpr.cn
http://www.dinnco.com/news/146583.html

相关文章:

  • hexo框架做网站百度推送
  • 网站开发论坛长沙网站se0推广优化公司
  • 企业网站建设参考资料优化营商环境指什么
  • 深圳集团网站建设专业seo推广如何做
  • 中英文版网站是怎么做的策划营销推广方案
  • 合肥做企业网站软文范文200字
  • 哪个建站系统好app拉新推广接单平台
  • 廊坊首页霸屏优化长春网站建设方案优化
  • 北京网站如何做推广怎么搜索网站
  • 网站建设和维护价格河北网站推广
  • 路南网站建设精准广告投放
  • 北京婚纱摄影网站今日头条热点新闻
  • jsp如何做动态网站完善的seo网站
  • 真实的彩票网站建设新冠疫情最新情况最新消息
  • 深圳南山网站开发线上营销推广公司
  • 软文怎么优化网站深圳seo专家
  • 江西建设厅教育网站网络优化师
  • 丹东振兴区哈尔滨优化调整人员流动管理
  • 佛山当地网站建设公司辽源seo
  • 山东网站建设是什么免费seo网站推广在线观看
  • 网站的常用建设技术有哪些百度推广客户端官方下载
  • 建设网站报价百度收录快速提交
  • 佛山外贸网站建设方案汕头网站推广排名
  • 做网站引流seo从入门到精通
  • wordpress威客主题企业排名优化公司
  • 手机什么网站可以设计楼房深圳搜索排名优化
  • 有趣网址之家 收藏全球最有趣的网站厦门零基础学seo
  • 电子商务网站建设项目规划书快速优化网站排名软件
  • 产业园区运营公司关键词优化价格
  • 网站建设论坛快速建站临沂seo推广外包