public class demo3 {
public static void main(String[] args) {
int i = 2020;
int count = 0;
for (int j = 1; j <= 2020; j++) {
String str = j + "";
for(int k = 0; k < str.length();k++) {
if (str.charAt(k) == '2') {//遍历字符串每个字符
count++;
}
}
}
System.out.println(count);
}
}
蓝桥杯十一届c组门牌制作
于 2023-03-03 18:52:43 首次发布