字符统计个数
字符个数统计
http://www.nowcoder.com/questionTerminal/eb94f6a5b2ba49c6ac72d40b5ce95f50
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); while(sc.hasNextLine()){ String s = sc.nextLine(); char[] cc = s.toCharArray(); int count = 0; HashSet<Character> set = new HashSet<>(); for(int i = 0; i < cc.length; ++i){ if(cc[i] >= 0 && cc[i] <= 127){ if(!set.contains(cc[i])){ set.add(cc[i]); count++; } } } System.out.println(count); } } }