久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      java實現(xiàn)計算字符串中不同字符或數(shù)字的個數(shù)

      java實現(xiàn)計算字符串中不同字符或數(shù)字的個數(shù)

      問題:

      根據(jù)提示輸入一行字符,這行字符可以是任意的,可以包含字母數(shù)字標點符號,特殊符號等,java程序會輸出你輸入字符串中各個類別字符的個數(shù)。

      結(jié)果展示:

      java實現(xiàn)計算字符串中不同字符或數(shù)字的個數(shù)

      免費學習視頻教程推薦:java視頻

      代碼展示:

      package com.one; import java.util.*; public class Flqgs { 	public static Scanner input = new Scanner(System.in); 	public static void main(String[] args) { 		System.out.println("請輸入一行字符串:"); 		String num = input.nextLine(); 		int digital = 0, character = 0, other = 0, blank = 0; 		char [] ch = num.toCharArray(); 		 		for(int i=0;i<ch.length;i++){ 			if(ch[i] >= 'a' && ch[i] <= 'z' || ch[i] >= 'A' && ch[i] <= 'z'){ 				character++; 			}else if(ch[i] >= '0' && ch[i] <= '9'){ 				digital++; 			}else if(ch[i] == ' '){ 				blank++; 			}else{ 				other++; 			} 		} 		System.out.println("字母個數(shù):"+character); 		System.out.println("數(shù)字個數(shù):"+digital); 		System.out.println("空格個數(shù):"+blank); 		System.out.println("其他個數(shù):"+other); 	} }

      相關(guān)文章教程推薦:java語言入門

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號