为了账号安全,请及时绑定邮箱和手机立即绑定

这个逻辑性,不好理解能解释下面。大神???感谢------

这个逻辑性,不好理解能解释下面。大神???感谢------

qq_小杜_1 2017-06-09 23:17:17
题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。import java.util.*;public class lianxi07 {public static void main(String[] args){int digital = 0;int character = 0;int other = 0;int blank = 0;char[] ch = null;Scanner sc = new Scanner(System.in);String s = sc.nextLine();--------------------------------------------下面的逻辑不太理解-----------------------------------------------ch = s.toCharArray();for(int i=0; i<ch.length; i++) {if(ch >= '0' && ch <= '9') {digital ++;} else if((ch >= 'a' && ch <= 'z') || ch > 'A' && ch <= 'Z') {character ++;} else if(ch == ' ') {blank ++;} else {other ++;}}---------------------------------------------------------------------------------------------------------------------System.out.println("数字个数: " + digital);System.out.println("英文字母个数: " + character);System.out.println("空格个数: " + blank);System.out.println("其他字符个数:" + other );}}
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 1818 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信