1到1000中有几个0

来源:百度知道 编辑:UC知道 时间:2024/05/21 09:30:54
一共出现的次数

StringBuffer str = new StringBuffer();
for (int i = 1; i <= 1000; i++) {
str.append(i);
}
String str2 = str.toString();

str2 = str2.replaceAll("[1|2|3|4|5|6|7|8|9]", "");

System.out.println(str2.length());

192个

擦 算错了 上面这位才是对的~ 汗颜中

一楼人才啊

1楼的为正解