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

          2010年12月21日

               摘要:   閱讀全文

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

          很簡單的,寫著玩的,沒技術含量
          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 應該干點什么 閱讀(7625) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 固安县| 清河县| 天镇县| 黎川县| 韶山市| 乾安县| 盐源县| 桦川县| 汕头市| 天全县| 萨嘎县| 台安县| 芦溪县| 赣榆县| 郎溪县| 绥江县| 大足县| 邵阳市| 仙居县| 柏乡县| 宝兴县| 柘荣县| 通道| 宜君县| 县级市| 饶阳县| 松滋市| 磴口县| 水城县| 肥西县| 大邑县| 交城县| 德安县| 迁安市| 确山县| 平南县| 和林格尔县| 花莲市| 卓资县| 建宁县| 确山县|