题解 | #统计字符#
统计字符
http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
import java.util.Scanner;
public class Main { public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String str = scanner.nextLine();
//英文
String aStr = str.replaceAll("([A-Za-z])", "");
int aCount = str.length() - aStr.length();
System.out.println(aCount);
//空格
String kongStr = str.replaceAll(" ", "");
int kongCount = str.length() - kongStr.length();
System.out.println(kongCount);
//数字
String numStr = str.replaceAll("([0-9])", "");
int numCount = str.length() - numStr.length();
System.out.println(numCount);
//其他
System.out.println(str.length() - aCount - kongCount - numCount);
}
}