提交时间:2024-05-12 21:13:45

运行 ID: 47260

#include<bits/stdc++.h> int main() { int L,R; //定义区间 int i,count=0; scanf("%d %d",&L,&R); for(i=L;i<=R;i++) { int k=i; while(k) //对数字的每一位进行分析 { int temp=k%10; if(temp==2) count++; k/=10; } } printf("%d",count); return 0; }