看了题解还是不知道哪里错了
#include <iostream> #include <cstdio> using namespace std; long long k,t,j=0; int main(){ scanf("%d%d",&k,&t); for(int y=k;y<=t;++y){ while(y!=0){ if(y%10==2) ++j; y/=10; } } printf("%d",j); return 0; }