题目:
分析:
枚举法+数字拆分(tmp % 10,tmp / 10)
代码实现:
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int l = in.nextInt(), r = in.nextInt();
int ret = 0;
for(int i = l; i <= r; i++){
int tmp = i;
while(tmp != 0){
if(tmp % 10 == 2) ret++;
tmp /= 10;
}
}
System.out.println(ret);
}
}