题解 | #字符个数统计# 学习华为笔试题
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
InputStream in = System.in;
int count = 0;
boolean[] seen = new boolean[128]; // 用于记录字符是否出现过
int c;
while ((c = in.read()) != '\n') {
if (c >= 0 && c <= 127 && !seen[c]) {
seen[c] = true; // 将字符标记为已经出现过
count++; // 不同字符个数加一
}
}
System.out.println(count); // 输出不同字符的个数
}
}



