posts - 2, comments - 0, trackbacks - 0, articles - 1

          2011年10月29日

               摘要:   閱讀全文

          posted @ 2011-10-29 23:27 應該干點什么 閱讀(207) | 評論 (0)編輯 收藏

          2010年12月21日

          很簡單的,寫著玩的,沒技術含量
          public static void main(String[] args) {
          // TODO Auto-generated method stub
          int abcCount=0;//英文字母個數
          int spaceCount=0;//空格鍵個數
          int numCount=0;//數字個數
          int otherCount=0;//其他字符個數
          Scanner scan=new Scanner(System.in);
          String str=scan.nextLine();
          char[] ch = str.toCharArray();
          for(int i=0;i<ch.length;i++){
          if(Character.isLetter(ch[i])){
          //判斷是否字母
          abcCount++;
          }
          else if(Character.isDigit(ch[i])){
          //判斷是否數字
          numCount++;
          }
          else if(Character.isSpaceChar(ch[i])){
          //判斷是否空格鍵
          spaceCount++;
          }
          else{
          //以上都不是則認為是其他字符
          otherCount++;
          }
          }
          System.out.println("字母個數:"+abcCount);
          System.out.println("數字個數:"+numCount);
          System.out.println("空格個數:"+spaceCount);
          System.out.println("其他字符個數:"+otherCount);
          }

          posted @ 2010-12-21 18:14 應該干點什么 閱讀(7626) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 安西县| 西青区| 鸡西市| 嵊州市| 南澳县| 全州县| 油尖旺区| 阜新| 婺源县| 中卫市| 柞水县| 河东区| 铜陵市| 翁源县| 聂荣县| 日土县| 普兰县| 噶尔县| 崇阳县| 当阳市| 松潘县| 吉安县| 锦州市| 如东县| 辉南县| 土默特左旗| 新建县| 崇文区| 南华县| 肇州县| 嘉峪关市| 潞西市| 鹰潭市| 乐山市| 册亨县| 武义县| 红安县| 古浪县| 潜山县| 什邡市| 南漳县|