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

          2011年10月29日

               摘要:   閱讀全文

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

          主站蜘蛛池模板: 温宿县| 云梦县| 汉源县| 西吉县| 芜湖县| 紫云| 兴国县| 黑水县| 合川市| 石家庄市| 克东县| 蓬莱市| 池州市| 赣榆县| 诸城市| 公主岭市| 准格尔旗| 轮台县| 迭部县| 偃师市| 普兰县| 盐亭县| 铜陵市| 仲巴县| 大邑县| 金川县| 柏乡县| 噶尔县| 盐城市| 怀化市| 藁城市| 长丰县| 马山县| 会东县| 石家庄市| 政和县| 梁山县| 高安市| 五峰| 广西| 乳源|