zoukankan      html  css  js  c++  java
  • 每日代码系列(5)

    
    
     1 import java.util.*;
     2 class O3_3 {
     3   public static void main(String args[ ]) {
     4     String s;
     5     char c;
     6     int nDig,nChar,nOther;
     7     nDig=nChar=nOther=0;
     8     Scanner reader=new Scanner(System.in);
     9     System.out.print("请输入字符串:");
    10     s=reader.nextLine();
    11     for(int i=0;i<s.length();i++) {
    12       c=s.charAt(i);
    13       if((c>='a'&&c<='z')||(c>='A'&&c<='Z')) {
    14         nChar++;
    15       }
    16       else if(c>='0'&&c<='9') {
    17         nDig++;
    18       }
    19       else {
    20         nOther++;
    21       }
    22     }
    23     System.out.println("字符串中含有字母:"+nChar+"个");
    24     System.out.println("字符串中含有数字:"+nDig+"个");
    25     System.out.println("字符串中含有其他符号:"+nOther+"个");
    26   }
    27 }

    抱歉,差点忘了发布,十分抱歉。厚着脸皮求一个推荐,如果喜欢这个系列,对以后比较期待的,评论告诉我。

  • 相关阅读:
    bzoj2818
    bzoj1901
    bzoj1010
    loj6277
    bzoj1001
    bzoj1787
    选项卡
    日期选择器
    去掉文本框的外边框
    bootstarp 模态框大小尺寸的控制
  • 原文地址:https://www.cnblogs.com/ljydbk/p/14064209.html
Copyright © 2011-2022 走看看